Skip to content

Commit

Permalink
More tests for cli_wallet.
Browse files Browse the repository at this point in the history
  • Loading branch information
wkedzierski authored and Mariusz-Trela committed Apr 25, 2019
1 parent a85a7ce commit e1dacd0
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
4 changes: 3 additions & 1 deletion python_scripts/tests/cli_wallet/tests/003_list_proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
else:
start = 0
call_args = {"start":start, "order_by":by, "order_direction":direct, "limit":10, "status":act, "last_id":""}
call_and_check(wallet.list_proposals, call_args, "args")
resp = last_message_as_json(call_and_check(wallet.list_proposals, call_args, "args"))
if not "result" in resp:
raise ArgsCheckException("No `result` in response")

except Exception as _ex:
log.exception(str(_ex))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
for direct in order_direction:
for act in active:
call_args = {"start":args.creator, "order_by":by, "order_direction":direct, "limit":10, "status":act, "last_id" : ""}
call_and_check(wallet.list_voter_proposals, call_args, "args")
resp = last_message_as_json( call_and_check(wallet.list_voter_proposals, call_args, "args"))
if not "result" in resp:
raise ArgsCheckException("No `result` in response")


except Exception as _ex:
Expand Down
4 changes: 3 additions & 1 deletion python_scripts/tests/cli_wallet/tests/005_find_proposals.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

for ids in id_sets:
call_args = {"id_set":ids}
call_and_check(wallet.find_proposals, call_args, "args")
resp = last_message_as_json(call_and_check(wallet.find_proposals, call_args, "args"))
if not "result" in resp:
raise ArgsCheckException("No `result` in response")

except Exception as _ex:
log.exception(str(_ex))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
log.info(resp_10)
if resp_10.find(error_msg_10) != -1:
raise ArgsCheckException("There should be no assertion `{0}`.".format(error_msg_10))
if not "result" in last_message_as_json(resp_10):
raise ArgsCheckException("No `result` in response")


except Exception as _ex:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/python3

from utils.test_utils import *
from utils.cmd_args import args
from utils.cli_wallet import CliWallet
from utils.logger import log, init_logger

if __name__ == "__main__":
try:
init_logger(__file__)
error = False
wallet = CliWallet( args.path,
args.server_rpc_endpoint,
args.cert_auth,
args.rpc_tls_endpoint,
args.rpc_tls_cert,
args.rpc_http_endpoint,
args.deamon,
args.rpc_allowip,
args.wallet_file,
args.chain_id )
wallet.set_and_run_wallet()

error_msg_x = "The value `x` for `_last_id` argument is invalid, it should be integer type."
resp_error_x = wallet.list_voter_proposals(args.creator, "creator", "asc", 50, "all", "x")
log.info(resp_error_x)
if resp_error_x.find(error_msg_x) == -1:
raise ArgsCheckException("Assertion `{0}` is required.".format(error_msg_x))

error_msg_y = "The value `y` for `_last_id` argument is invalid, it should be integer type."
resp_error_y = wallet.list_voter_proposals(args.creator, "creator", "asc", 50, "all", "y")
log.info(resp_error_y)
if resp_error_y.find(error_msg_y) == -1:
raise ArgsCheckException("Assertion `{0}` is required.".format(error_msg_y))

error_msg_10 = "The value `10` for `_last_id` argument is invalid, it should be integer type."
resp_10 = wallet.list_voter_proposals(args.creator, "creator", "asc", 50, "all", "10")
log.info(resp_10)
if resp_10.find(error_msg_10) != -1:
raise ArgsCheckException("There should be no assertion `{0}`.".format(error_msg_10))
if not "result" in last_message_as_json(resp_10):
raise ArgsCheckException("No `result` in response")


except Exception as _ex:
log.exception(str(_ex))
error = True
finally:
if error:
log.error("TEST `{0}` failed".format(__file__))
exit(1)
else:
log.info("TEST `{0}` passed".format(__file__))
exit(0)

4 changes: 3 additions & 1 deletion python_scripts/tests/cli_wallet/tests/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def check_call_args(_call_args, _response, _arg_prefix):

def call_and_check(_func, _call_args, _arg_prefix):
response = _func(*_call_args.values())
log.info("Call response: {0}".format(response))
check_call_args(_call_args, response, _arg_prefix)
return response


def call_and_check_transaction(_func, _call_args, _arg_prefix, _broadcast):
Expand Down Expand Up @@ -132,4 +134,4 @@ def make_user_for_tests(_cli_wallet, _value_for_vesting = None, _value_for_tran
_cli_wallet.transfer_to_vesting( args.creator, creator, value_for_vesting, "true")
_cli_wallet.transfer( args.creator, creator, value_for_transfer_tests, "initial transfer", "true" )
_cli_wallet.transfer( args.creator, creator, value_for_transfer_tbd, "initial transfer", "true")
return creator, receiver
return creator, receiver

0 comments on commit e1dacd0

Please sign in to comment.