-
Notifications
You must be signed in to change notification settings - Fork 0
Transfer tokens from unfrozen to operational balance #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Art17
wants to merge
6
commits into
develop
Choose a base branch
from
transfer-from-unfrozen-to-operational
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f8d521
Transfer tokens from unfrozen to operational balance
4c24e3d
update readme
8e36b2a
flake8 code update
9aa1eb5
review summary
4742adb
a transfer from unfrozen to operational form added
7dfa36e
batch_identifier field
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
tests/node_account/test_transfer_tokens_from_unfrozen_to_operational.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,100 @@ | ||||||
| """ | ||||||
| Provide tests for command line interface's node account transfer tokens from unfrozen to operational balance. | ||||||
| """ | ||||||
| import json | ||||||
|
|
||||||
| import pytest | ||||||
| from click.testing import CliRunner | ||||||
|
|
||||||
| from cli.constants import ( | ||||||
| FAILED_EXIT_FROM_COMMAND_CODE, | ||||||
| INCORRECT_ENTERED_COMMAND_CODE, | ||||||
| PASSED_EXIT_FROM_COMMAND_CODE, | ||||||
| ) | ||||||
| from cli.entrypoint import cli | ||||||
| from cli.utils import dict_to_pretty_json | ||||||
|
|
||||||
|
|
||||||
|
Art17 marked this conversation as resolved.
|
||||||
| def test_transfer_tokens_from_unfrozen_to_operational(mocker, transaction): | ||||||
| """ | ||||||
| Case: transfer tokens from unfrozen reputational balance to operational balance. | ||||||
| Expect: transaction's batch identifier is returned. | ||||||
| """ | ||||||
| mock_get_node_private_key = mocker.patch('cli.config.NodePrivateKey.get') | ||||||
| mock_get_node_private_key.return_value = '42dada12f863528bd456785d8c544154db6ec9455be2c123d91b687df3697314' | ||||||
|
|
||||||
| mock_node_account_transfer_tokens_from_unfrozen_to_operational = \ | ||||||
| mocker.patch('cli.node_account.service.loop.run_until_complete') | ||||||
| mock_node_account_transfer_tokens_from_unfrozen_to_operational.return_value = transaction | ||||||
|
|
||||||
| runner = CliRunner() | ||||||
| result = runner.invoke(cli, [ | ||||||
| 'node-account', | ||||||
| 'transfer-tokens-from-unfrozen-to-operational', | ||||||
| '--amount', | ||||||
| 1000, | ||||||
| ]) | ||||||
|
|
||||||
| transaction_batch_identifier = json.loads(result.output).get('result').get('batch_identifier') | ||||||
|
|
||||||
| assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code | ||||||
| assert transaction.batch_id == transaction_batch_identifier | ||||||
|
|
||||||
|
|
||||||
| def test_transfer_tokens_from_unfrozen_to_operational_invalid_amount(mocker, transaction): | ||||||
| """ | ||||||
| Case: transfer tokens from unfrozen reputational balance to operational balance with invalid amount. | ||||||
| Expect: amount is not a valid integer error message. | ||||||
| """ | ||||||
| invalid_amount = 'je682' | ||||||
|
|
||||||
| mock_get_node_private_key = mocker.patch('cli.config.NodePrivateKey.get') | ||||||
| mock_get_node_private_key.return_value = '42dada12f863528bd456785d8c544154db6ec9455be2c123d91b687df3697314' | ||||||
|
|
||||||
| mock_node_account_transfer_tokens_from_unfrozen_to_operational = \ | ||||||
| mocker.patch('cli.node_account.service.loop.run_until_complete') | ||||||
| mock_node_account_transfer_tokens_from_unfrozen_to_operational.return_value = transaction | ||||||
|
|
||||||
| runner = CliRunner() | ||||||
| result = runner.invoke(cli, [ | ||||||
| 'node-account', | ||||||
| 'transfer-tokens-from-unfrozen-to-operational', | ||||||
| '--amount', | ||||||
| invalid_amount, | ||||||
| ]) | ||||||
|
|
||||||
| assert INCORRECT_ENTERED_COMMAND_CODE == result.exit_code | ||||||
| assert f'{invalid_amount} is not a valid integer' in result.output | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize('insufficient_amount', [-1, 0]) | ||||||
| def test_transfer_tokens_from_unfrozen_to_operational_insufficient_amount(mocker, transaction, insufficient_amount): | ||||||
| """ | ||||||
| Case: transfer tokens from unfrozen reputational balance to operational balance with insufficient amount. | ||||||
| Expect: amount must be greater than 0 error message. | ||||||
| """ | ||||||
| mock_get_node_private_key = mocker.patch('cli.config.NodePrivateKey.get') | ||||||
| mock_get_node_private_key.return_value = '42dada12f863528bd456785d8c544154db6ec9455be2c123d91b687df3697314' | ||||||
|
|
||||||
| mock_node_account_transfer_tokens_from_unfrozen_to_operational = \ | ||||||
| mocker.patch('cli.node_account.service.loop.run_until_complete') | ||||||
| mock_node_account_transfer_tokens_from_unfrozen_to_operational.return_value = transaction | ||||||
|
|
||||||
| runner = CliRunner() | ||||||
| result = runner.invoke(cli, [ | ||||||
| 'node-account', | ||||||
| 'transfer-tokens-from-unfrozen-to-operational', | ||||||
| '--amount', | ||||||
| insufficient_amount, | ||||||
| ]) | ||||||
|
|
||||||
| expected_error = { | ||||||
| 'errors': { | ||||||
| 'amount': [ | ||||||
| f'Amount must be greater than 0.', | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ], | ||||||
| }, | ||||||
| } | ||||||
|
|
||||||
| assert FAILED_EXIT_FROM_COMMAND_CODE == result.exit_code | ||||||
| assert dict_to_pretty_json(expected_error) in result.output | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.