Skip to content

Commit

Permalink
fix(queries): make pytests pass
Browse files Browse the repository at this point in the history
Signed-off-by: ⭐️NINIKA⭐️ <[email protected]>
  • Loading branch information
DCNick3 committed Nov 18, 2024
1 parent 3965e8c commit 241c3ce
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/iroha_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ mod filter {
#[derive(Clone, Debug, clap::Parser)]
pub struct AssetDefinitionFilter {
/// Predicate for filtering given as JSON5 string
#[clap(value_parser = parse_json5::<CompoundPredicate<Asset>>)]
#[clap(value_parser = parse_json5::<CompoundPredicate<AssetDefinition>>)]
pub predicate: CompoundPredicate<AssetDefinition>,
}

Expand Down
16 changes: 11 additions & 5 deletions pytests/iroha_cli_tests/src/iroha_cli/have.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def domain(expected, owned_by=None):
"""

def domain_in_domains() -> bool:
domains = iroha.list_filter({"Atom": {"Id": {"Equals": expected}}}).domains()
domains = iroha.list_filter(
{"Atom": {"Id": {"Atom": {"Equals": expected}}}}
).domains()
if not expected_in_actual(expected, domains):
return False
if owned_by:
Expand All @@ -62,7 +64,9 @@ def account(expected):
"""

def account_in_accounts() -> bool:
accounts = iroha.list_filter({"Atom": {"Id": {"Equals": expected}}}).accounts()
accounts = iroha.list_filter(
{"Atom": {"Id": {"Atom": {"Equals": expected}}}}
).accounts()
return expected_in_actual(expected, accounts)

return iroha_cli.wait_for(account_in_accounts)
Expand All @@ -78,7 +82,7 @@ def asset_definition(expected):

def asset_definition_in_asset_definitions() -> bool:
asset_definitions = iroha.list_filter(
{"Atom": {"Id": {"Equals": expected}}}
{"Atom": {"Id": {"Atom": {"Equals": expected}}}}
).asset_definitions()
return expected_in_actual(expected, asset_definitions)

Expand All @@ -94,7 +98,9 @@ def asset(expected):
"""

def asset_in_assets() -> bool:
assets = iroha.list_filter({"Atom": {"Id": {"Equals": expected}}}).assets()
assets = iroha.list_filter(
{"Atom": {"Id": {"Atom": {"Equals": expected}}}}
).assets()
return expected_in_actual(expected, assets)

return iroha_cli.wait_for(asset_in_assets)
Expand All @@ -111,7 +117,7 @@ def asset_has_quantity(expected_asset_id, expected_quantity):

def check_quantity() -> bool:
assets = iroha.list_filter(
{"Atom": {"Id": {"Equals": expected_asset_id}}}
{"Atom": {"Id": {"Atom": {"Equals": expected_asset_id}}}}
).assets()
actual_quantity = None
for asset_item in assets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def condition():
domain = GIVEN_registered_account.domain
with allure.step(f"WHEN iroha_cli query accounts " f'in the "{domain}" domain'):
accounts = iroha.list_filter(
{"Atom": {"Id": {"DomainId": {"Equals": domain}}}}
{"Atom": {"Id": {"Domain": {"Atom": {"Equals": domain}}}}}
).accounts()
with allure.step("THEN Iroha should return only accounts with this domain"):
allure.attach(
Expand All @@ -33,7 +33,7 @@ def condition():
f'WHEN iroha_cli query accounts with account id "{account_id}"'
):
accounts = iroha.list_filter(
{"Atom": {"Id": {"Equals": account_id}}}
{"Atom": {"Id": {"Atom": {"Equals": account_id}}}}
).accounts()
with allure.step("THEN Iroha should return only accounts with this id"):
allure.attach(
Expand Down
12 changes: 9 additions & 3 deletions pytests/iroha_cli_tests/test/assets/test_assets_query_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ def condition():
)
with allure.step(f"WHEN iroha_cli query assets" f'in the "{domain}" domain'):
assets = iroha.list_filter(
{"Atom": {"Id": {"DefinitionId": {"DomainId": {"Equals": domain}}}}}
{
"Atom": {
"Id": {"Definition": {"Domain": {"Atom": {"Equals": domain}}}}
}
}
).assets()
with allure.step("THEN Iroha should return only assets with this domain"):
allure.attach(
Expand All @@ -38,7 +42,7 @@ def condition():
)
with allure.step(f'WHEN iroha_cli query assets with name "{name}"'):
assets = iroha.list_filter(
{"Atom": {"Id": {"DefinitionId": {"Name": {"Equals": name}}}}}
{"Atom": {"Id": {"Definition": {"Name": {"Atom": {"Equals": name}}}}}}
).assets()
with allure.step("THEN Iroha should return only assets with this name"):
allure.attach(
Expand All @@ -64,7 +68,9 @@ def condition():
+ GIVEN_currently_authorized_account.domain
)
with allure.step(f'WHEN iroha_cli query assets with asset id "{asset_id}"'):
assets = iroha.list_filter({"Atom": {"Id": {"Equals": asset_id}}}).assets()
assets = iroha.list_filter(
{"Atom": {"Id": {"Atom": {"Equals": asset_id}}}}
).assets()
with allure.step("THEN Iroha should return only assets with this id"):
allure.attach(
json.dumps(assets),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def condition():
f'WHEN iroha_cli query domains filtered by name "{domain_name}"'
):
domains = iroha.list_filter(
{"Atom": {"Id": {"Equals": domain_name}}}
{"Atom": {"Id": {"Atom": {"Equals": domain_name}}}}
).domains()
with allure.step(
f'THEN Iroha should return only return domains with "{domain_name}" name'
Expand Down

0 comments on commit 241c3ce

Please sign in to comment.