Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
9ac8ef4c
Commit
9ac8ef4c
authored
Aug 27, 2019
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rest Gateway: first tests
parent
21605a3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
manage_sys_paths.py
rest-gateway/tests/manage_sys_paths.py
+7
-0
test_blockchain_trace.py
rest-gateway/tests/test_blockchain_trace.py
+59
-0
No files found.
rest-gateway/tests/manage_sys_paths.py
0 → 100644
View file @
9ac8ef4c
# add modules folder to interpreter path
import
sys
import
os
modules_paths
=
[
'../app/'
,
'../../modules/'
]
for
path
in
modules_paths
:
if
os
.
path
.
exists
(
path
):
sys
.
path
.
insert
(
1
,
path
)
rest-gateway/tests/test_blockchain_trace.py
0 → 100644
View file @
9ac8ef4c
import
unittest
import
manage_sys_paths
import
rest.blockchain_trace
as
blockchain_trace
class
Test_BlockchainTrace
(
unittest
.
TestCase
):
def
_get_valid_input
(
self
):
return
{
"ApplicationType"
:
"string"
,
"Metadata"
:
{},
"ResourceIds"
:
"string"
,
"ResourceMd5"
:
"string"
,
"ResourceState"
:
"string"
,
"Timestamp"
:
"2019-08-27T14:00:48.587Z"
,
"TransactionFrom"
:
"string"
,
"TransactionFromLatLng"
:
"string"
,
"TransactionId"
:
"string"
,
"TransactionTo"
:
"string"
,
"TransactionToLatLng"
:
"string"
,
"TransferredAsset"
:
"string"
}
def
test_isBlockchainTraceValid_validInputAndTypes
(
self
):
input
=
self
.
_get_valid_input
()
self
.
assertTrue
(
blockchain_trace
.
isBlockchainTraceValid
(
input
),
"Trace should be valid"
)
def
test_isBlockchainTraceValid_invalidMetadataInputType
(
self
):
input
=
self
.
_get_valid_input
()
input
[
"Metadata"
]
=
"string"
self
.
assertFalse
(
blockchain_trace
.
isBlockchainTraceValid
(
input
),
"Metadata type should be invalid"
)
def
test_isBlockchainTraceValid_invalidTransactionFromLatLngInputType
(
self
):
input
=
self
.
_get_valid_input
()
input
[
"TransactionFromLatLng"
]
=
[
"55.1"
,
"44.1"
]
self
.
assertFalse
(
blockchain_trace
.
isBlockchainTraceValid
(
input
),
"TransactionFromLatLng type should be invalid"
)
def
test_isBlockchainTraceValid_emptyInput
(
self
):
input
=
{}
self
.
assertFalse
(
blockchain_trace
.
isBlockchainTraceValid
(
input
),
"Empty input should not be accepted"
)
def
test_isBlockchainTraceValid_missingKeys
(
self
):
input
=
{
"ApplicationType"
:
"string"
,
"Metadata"
:
{},
"ResourceIds"
:
"string"
,
"ResourceMd5"
:
"string"
,
"ResourceState"
:
"string"
,
"TransactionFrom"
:
"string"
,
"TransactionFromLatLng"
:
"string"
,
"TransactionId"
:
"string"
,
"TransactionTo"
:
"string"
,
"TransactionToLatLng"
:
"string"
,
"TransferredAsset"
:
"string"
}
self
.
assertFalse
(
blockchain_trace
.
isBlockchainTraceValid
(
input
),
"Input should not be accepted because timestamp is missing"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment