forked from hyperledger-iroha/iroha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] hyperledger-iroha#2398: Add integration tests for query fi…
…lters Signed-off-by: Shanin Roman <[email protected]>
- Loading branch information
Showing
9 changed files
with
177 additions
and
100 deletions.
There are no files selected for viewing
This file contains 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 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 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
51 changes: 51 additions & 0 deletions
51
client_cli/pytests/test/accounts/test_accounts_query_filters.py
This file contains 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,51 @@ | ||
import json | ||
import allure | ||
|
||
from src.client_cli import iroha, iroha, client_cli | ||
|
||
# using existing account to have at least one account in response | ||
def test_filter_by_domain(GIVEN_new_one_existence_account): | ||
def condition(): | ||
domain = GIVEN_new_one_existence_account.domain | ||
with allure.step( | ||
f'WHEN client_cli query accounts ' | ||
f'in the "{domain}" domain'): | ||
accounts = iroha.list_filter(f'{{"Identifiable": {{"EndsWith": "@{domain}"}}}}').accounts() | ||
with allure.step( | ||
f'THEN Iroha should return only accounts with this domain'): | ||
allure.attach( | ||
json.dumps(accounts), | ||
name='accounts', | ||
attachment_type=allure.attachment_type.JSON) | ||
return accounts and all(account.endswith(domain) for account in accounts) | ||
client_cli.wait_for(condition) | ||
|
||
def test_filter_by_account_name(GIVEN_new_one_existence_account): | ||
def condition(): | ||
name = GIVEN_new_one_existence_account.name | ||
with allure.step( | ||
f'WHEN client_cli query accounts with name "{name}"'): | ||
accounts = iroha.list_filter(f'{{"Identifiable": {{"StartsWith": "{name}@"}}}}').accounts() | ||
with allure.step( | ||
f'THEN Iroha should return only accounts with this name'): | ||
allure.attach( | ||
json.dumps(accounts), | ||
name='accounts', | ||
attachment_type=allure.attachment_type.JSON) | ||
return accounts and all(account.startswith(name) for account in accounts) | ||
client_cli.wait_for(condition) | ||
|
||
def test_filter_by_account_id(GIVEN_new_one_existence_account): | ||
def condition(): | ||
account_id = GIVEN_new_one_existence_account.name + "@" + GIVEN_new_one_existence_account.domain | ||
with allure.step( | ||
f'WHEN client_cli query accounts with account id "{account_id}"'): | ||
accounts = iroha.list_filter(f'{{"Identifiable": {{"Is": "{account_id}"}}}}').accounts() | ||
with allure.step( | ||
f'THEN Iroha should return only accounts with this id'): | ||
allure.attach( | ||
json.dumps(accounts), | ||
name='accounts', | ||
attachment_type=allure.attachment_type.JSON) | ||
return accounts and all(account == account_id for account in accounts) | ||
client_cli.wait_for(condition) |
54 changes: 54 additions & 0 deletions
54
client_cli/pytests/test/assets/test_assets_query_filters.py
This file contains 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,54 @@ | ||
import json | ||
import allure | ||
|
||
from src.client_cli import iroha, iroha, client_cli | ||
|
||
# using existing account with asset to have at least one in response | ||
def test_filter_by_domain(GIVEN_currently_account_quantity_with_two_quantity_of_asset): | ||
def condition(): | ||
domain = GIVEN_currently_account_quantity_with_two_quantity_of_asset.domain | ||
with allure.step( | ||
f'WHEN client_cli query assets' | ||
f'in the "{domain}" domain'): | ||
assets = iroha.list_filter( | ||
f'{{"Or": [{{"Identifiable": {{"Contains": "#{domain}#"}}}}, {{"And": [{{"Identifiable": {{"Contains": "##"}}}}, {{"Identifiable": {{"EndsWith": "@{domain}"}}}}]}}]}}' | ||
).assets() | ||
with allure.step( | ||
f'THEN Iroha should return only assets with this domain'): | ||
allure.attach( | ||
json.dumps(assets), | ||
name='assets', | ||
attachment_type=allure.attachment_type.JSON) | ||
return assets and all(f'#{domain}#' in asset or ('##' in asset and f"@{domain}" in asset) for asset in assets) | ||
client_cli.wait_for(condition) | ||
|
||
|
||
def test_filter_by_asset_name(GIVEN_currently_account_quantity_with_two_quantity_of_asset): | ||
def condition(): | ||
name = GIVEN_currently_account_quantity_with_two_quantity_of_asset.name | ||
with allure.step( | ||
f'WHEN client_cli query assets with name "{name}"'): | ||
assets = iroha.list_filter(f'{{"Identifiable": {{"StartsWith": "{name}#"}}}}').assets() | ||
with allure.step( | ||
f'THEN Iroha should return only assets with this name'): | ||
allure.attach( | ||
json.dumps(assets), | ||
name='assets', | ||
attachment_type=allure.attachment_type.JSON) | ||
return assets and all(asset.startswith(name) for asset in assets) | ||
client_cli.wait_for(condition) | ||
|
||
def test_filter_by_asset_id(GIVEN_currently_authorized_account, GIVEN_currently_account_quantity_with_two_quantity_of_asset): | ||
def condition(): | ||
asset_id = GIVEN_currently_account_quantity_with_two_quantity_of_asset.name + "##" + GIVEN_currently_authorized_account.name + "@" + GIVEN_currently_authorized_account.domain | ||
with allure.step( | ||
f'WHEN client_cli query assets with asset id "{asset_id}"'): | ||
assets = iroha.list_filter(f'{{"Identifiable": {{"Is": "{asset_id}"}}}}').assets() | ||
with allure.step( | ||
f'THEN Iroha should return only assets with this id'): | ||
allure.attach( | ||
json.dumps(assets), | ||
name='assets', | ||
attachment_type=allure.attachment_type.JSON) | ||
return assets and all(asset == asset_id for asset in assets) | ||
client_cli.wait_for(condition) |
This file contains 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 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
19 changes: 19 additions & 0 deletions
19
client_cli/pytests/test/domains/test_domains_query_filters.py
This file contains 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,19 @@ | ||
import json | ||
import allure | ||
|
||
from src.client_cli import iroha, iroha, client_cli | ||
|
||
def test_filter_by_domain(GIVEN_new_one_existence_domain): | ||
def condition(): | ||
domain_name = GIVEN_new_one_existence_domain.name | ||
with allure.step( | ||
f'WHEN client_cli query domains filtered by name "{domain_name}"'): | ||
domains = iroha.list_filter(f'{{"Identifiable": {{"Is": "{domain_name}"}}}}').domains() | ||
with allure.step( | ||
f'THEN Iroha should return only return domains with "{domain_name}" name'): | ||
allure.attach( | ||
json.dumps(domains), | ||
name='domains', | ||
attachment_type=allure.attachment_type.JSON) | ||
return domains and all(domain == domain_name for domain in domains) | ||
client_cli.wait_for(condition) |
Binary file not shown.