Skip to content

Commit

Permalink
Add check for test case get swap info, refactor readme
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiia-bilova committed May 3, 2019
1 parent a92a23d commit 306e861
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* [Requirements](#getting-started-requirements)
* [Installation](#installation)
* [Usage](#usage)
* [Nodes](#nodes)
* [Configuration file](#configuration-file)
* [Service](#service)
* [Account](#account)
Expand Down
16 changes: 10 additions & 6 deletions tests/atomic_swap/test_get_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from cli.entrypoint import cli
from cli.utils import dict_to_pretty_json

SWAP_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE = '033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808'


def test_get_swap_info():
"""
Expand All @@ -28,17 +30,19 @@ def test_get_swap_info():
'atomic-swap',
'get-info',
'--id',
'033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808',
SWAP_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE,
'--node-url',
NODE_27_IN_TESTNET_ADDRESS,
])

swap_info = json.loads(result.output).get('result').get('information')
swap_identifier = swap_info.get('swap_id')

assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code
assert SWAP_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE == swap_identifier
assert re.match(pattern=ADDRESS_REGEXP, string=swap_info.get('sender_address')) is not None
assert re.match(pattern=ADDRESS_REGEXP, string=swap_info.get('receiver_address')) is not None
assert re.match(pattern=SWAP_IDENTIFIER_REGEXP, string=swap_info.get('swap_id')) is not None
assert re.match(pattern=SWAP_IDENTIFIER_REGEXP, string=swap_identifier) is not None
assert isinstance(int(float(swap_info.get('amount'))), int)
assert isinstance(swap_info.get('is_initiator'), bool)

Expand All @@ -56,7 +60,7 @@ def test_get_swap_info_without_node_url(mocker, swap_info):
'atomic-swap',
'get-info',
'--id',
'033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808',
SWAP_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE,
])

expected_result = {
Expand Down Expand Up @@ -135,7 +139,7 @@ def test_get_swap_info_non_existing_node_url():
'atomic-swap',
'get-info',
'--id',
'033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808',
SWAP_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE,
'--node-url',
non_existing_node_url,
])
Expand All @@ -160,7 +164,7 @@ def test_get_swap_info_invalid_node_url():
'atomic-swap',
'get-info',
'--id',
'033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808',
SWAP_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE,
'--node-url',
invalid_node_url,
])
Expand Down Expand Up @@ -188,7 +192,7 @@ def test_get_swap_info_node_url_with_protocol(node_url_with_protocol):
'atomic-swap',
'get-info',
'--id',
'033402fe1346742486b15a3a9966eb5249271025fc7fb0b37ed3fdb4bcce6808',
SWAP_IDENTIFIER_PRESENTED_ON_THE_TEST_NODE,
'--node-url',
node_url_with_protocol,
])
Expand Down

0 comments on commit 306e861

Please sign in to comment.