From 594c7134f17f586ccc7b39142d6f64a8cd70dc7c Mon Sep 17 00:00:00 2001 From: anders-albert Date: Sat, 9 Nov 2024 20:01:36 +0100 Subject: [PATCH] tests; query property to method --- ...query_property.py => test_query_method.py} | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) rename tests/test_integration/{test_query_property.py => test_query_method.py} (67%) diff --git a/tests/test_integration/test_query_property.py b/tests/test_integration/test_query_method.py similarity index 67% rename from tests/test_integration/test_query_property.py rename to tests/test_integration/test_query_method.py index 6ca8b2e50..382b2d744 100644 --- a/tests/test_integration/test_query_property.py +++ b/tests/test_integration/test_query_method.py @@ -5,7 +5,7 @@ def test_query_across_direct_relation(omni_client: OmniClient) -> None: - items = omni_client.connection_item_a.query.other_direct.list_full(limit=5) + items = omni_client.connection_item_a.query().other_direct.list_full(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemAList) @@ -19,7 +19,7 @@ def test_query_across_direct_relation(omni_client: OmniClient) -> None: def test_query_list_method(omni_client: OmniClient) -> None: - items = omni_client.connection_item_a.query.other_direct.list_connection_item_c_node(limit=5) + items = omni_client.connection_item_a.query().other_direct.list_connection_item_c_node(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemCNodeList) @@ -27,7 +27,7 @@ def test_query_list_method(omni_client: OmniClient) -> None: def test_query_list_method_with_filter(omni_client: OmniClient) -> None: - items = omni_client.connection_item_a.query.outwards.name.prefix("A").list_connection_item_b(limit=5) + items = omni_client.connection_item_a.query().outwards.name.prefix("A").list_connection_item_b(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemBList) @@ -37,8 +37,8 @@ def test_query_list_method_with_filter(omni_client: OmniClient) -> None: def test_query_list_method_with_filter_query(omni_client: OmniClient) -> None: - items = omni_client.connection_item_a.query.outwards.name.prefix("A").list_full(limit=5) - items_reversed = omni_client.connection_item_b.query.name.prefix("A").inwards.list_connection_item_a(limit=5) + items = omni_client.connection_item_a.query().outwards.name.prefix("A").list_full(limit=5) + items_reversed = omni_client.connection_item_b.query().name.prefix("A").inwards.list_connection_item_a(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemAList) @@ -62,8 +62,8 @@ def test_query_list_method_with_filter_query(omni_client: OmniClient) -> None: def test_query_list_full_inwards_edge(omni_client: OmniClient) -> None: - items = omni_client.connection_item_b.query.inwards.name.prefix("M").list_full(limit=5) - items_reversed = omni_client.connection_item_a.query.name.prefix("M").outwards.list_connection_item_b(limit=5) + items = omni_client.connection_item_b.query().inwards.name.prefix("M").list_full(limit=5) + items_reversed = omni_client.connection_item_a.query().name.prefix("M").outwards.list_connection_item_b(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemBList) @@ -74,9 +74,9 @@ def test_query_list_full_inwards_edge(omni_client: OmniClient) -> None: def test_query_list_full_across_direct_relation(omni_client: OmniClient) -> None: - items = omni_client.connection_item_d.query.direct_single.name.prefix("E").list_full(limit=5) - items_reversed = omni_client.connection_item_e.query.name.prefix("E").direct_reverse_single.list_connection_item_d( - limit=5 + items = omni_client.connection_item_d.query().direct_single.name.prefix("E").list_full(limit=5) + items_reversed = ( + omni_client.connection_item_e.query().name.prefix("E").direct_reverse_single.list_connection_item_d(limit=5) ) assert len(items) > 0 @@ -88,8 +88,10 @@ def test_query_list_full_across_direct_relation(omni_client: OmniClient) -> None def test_query_list_full_across_reverse_direct_relation(omni_client: OmniClient) -> None: - items = omni_client.connection_item_e.query.direct_reverse_single.name.prefix("M").list_full(limit=5) - items_reversed = omni_client.connection_item_d.query.name.prefix("M").direct_single.list_connection_item_e(limit=5) + items = omni_client.connection_item_e.query().direct_reverse_single.name.prefix("M").list_full(limit=5) + items_reversed = ( + omni_client.connection_item_d.query().name.prefix("M").direct_single.list_connection_item_e(limit=5) + ) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemEList) @@ -100,7 +102,7 @@ def test_query_list_full_across_reverse_direct_relation(omni_client: OmniClient) def test_query_across_edge_without_properties(omni_client: OmniClient) -> None: - items = omni_client.connection_item_a.query.outwards.list_full(limit=5) + items = omni_client.connection_item_a.query().outwards.list_full(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemAList) @@ -111,7 +113,7 @@ def test_query_across_edge_without_properties(omni_client: OmniClient) -> None: @pytest.mark.skip("Missing test data") def test_query_across_edge_properties(omni_client: OmniClient) -> None: - items = omni_client.connection_item_f.query.outwards_multi.end_node.list_full(limit=5) + items = omni_client.connection_item_f.query().outwards_multi.end_node.list_full(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemFList) @@ -122,20 +124,18 @@ def test_query_across_edge_properties(omni_client: OmniClient) -> None: def test_query_circular_raises_value_error(omni_client: OmniClient) -> None: with pytest.raises(ValueError) as e: - omni_client.connection_item_a.query.outwards.inwards.outwards.list_full(limit=5) + omni_client.connection_item_a.query().outwards.inwards.outwards.list_full(limit=5) assert "Circular" in str(e.value) -def test_query_passer_reversed_list_value_error(omni_client: OmniClient) -> None: - with pytest.raises(ValueError) as e: - omni_client.connection_item_e.query.direct_reverse_multi.outwards_single.list_full(limit=5) - - assert "Cannot query across a reverse-list connection." in str(e.value) +def test_query_across_reversed_list(omni_client: OmniClient) -> None: + result = omni_client.connection_item_e.query().direct_reverse_multi.list_full(limit=5) + assert result def test_query_end_on_reverse_direct_relation_to_list(omni_client: OmniClient) -> None: - items = omni_client.connection_item_e.query.direct_reverse_multi.list_connection_item_d(limit=5) + items = omni_client.connection_item_e.query().direct_reverse_multi.list_connection_item_d(limit=5) assert len(items) > 0 assert isinstance(items, dc.ConnectionItemDList) @@ -143,14 +143,14 @@ def test_query_end_on_reverse_direct_relation_to_list(omni_client: OmniClient) - def test_query_list_across_edge_limit(wind_client: WindmillClient) -> None: - items = wind_client.windmill.query.name.equals("hornsea_1_mill_1").blades.list_blade(limit=5) + items = wind_client.windmill.query().name.equals("hornsea_1_mill_1").blades.list_blade(limit=5) assert len(items) > 0 assert items.dump() def test_query_across_reverse_direct_relation_to_list_full(omni_client: OmniClient) -> None: - items = omni_client.connection_item_e.query.direct_reverse_multi.list_full(limit=5) + items = omni_client.connection_item_e.query().direct_reverse_multi.list_full(limit=5) assert len(items) > 0 assert items.dump()