Skip to content

Commit

Permalink
tests; query property to method
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino committed Nov 9, 2024
1 parent 9b4a5e0 commit 594c713
Showing 1 changed file with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,15 +19,15 @@ 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)
assert items.dump()


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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -122,35 +124,33 @@ 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)
assert items.dump()


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()

0 comments on commit 594c713

Please sign in to comment.