diff --git a/test/async_/test_match_api.py b/test/async_/test_match_api.py index a69b9834..81944871 100644 --- a/test/async_/test_match_api.py +++ b/test/async_/test_match_api.py @@ -25,6 +25,7 @@ AsyncTraversal, Collect, Last, + NodeNameResolver, Optional, RawCypher, RelationNameResolver, @@ -768,6 +769,19 @@ async def test_annotate_and_collect(): ) assert len(result[0][1][0]) == 2 # 2 species must be there + result = ( + await Supplier.nodes.traverse_relations("coffees__species") + .annotate( + all_species=Collect(NodeNameResolver("coffees__species"), distinct=True), + all_species_rels=Collect( + RelationNameResolver("coffees__species"), distinct=True + ), + ) + .all() + ) + assert len(result[0][1][0]) == 2 # 2 species must be there + assert len(result[0][2][0]) == 3 # 3 species relations must be there + @mark_async_test async def test_resolve_subgraph(): @@ -900,11 +914,11 @@ async def test_intermediate_transform(): await nescafe.species.connect(arabica) result = ( - await Coffee.nodes.traverse_relations(suppliers="suppliers") + await Coffee.nodes.fetch_relations("suppliers") .intermediate_transform( { "coffee": "coffee", - "suppliers": "suppliers", + "suppliers": NodeNameResolver("suppliers"), "r": RelationNameResolver("suppliers"), }, ordering=["-r.since"], @@ -927,6 +941,15 @@ async def test_intermediate_transform(): "test": Collect("suppliers"), } ) + with raises( + ValueError, + match=re.escape( + r"You must provide one variable at least when calling intermediate_transform()" + ), + ): + Coffee.nodes.traverse_relations(suppliers="suppliers").intermediate_transform( + {} + ) @mark_async_test diff --git a/test/sync_/test_match_api.py b/test/sync_/test_match_api.py index ff421a4b..e47e3396 100644 --- a/test/sync_/test_match_api.py +++ b/test/sync_/test_match_api.py @@ -23,6 +23,7 @@ from neomodel.sync_.match import ( Collect, Last, + NodeNameResolver, NodeSet, Optional, QueryBuilder, @@ -756,6 +757,19 @@ def test_annotate_and_collect(): ) assert len(result[0][1][0]) == 2 # 2 species must be there + result = ( + Supplier.nodes.traverse_relations("coffees__species") + .annotate( + all_species=Collect(NodeNameResolver("coffees__species"), distinct=True), + all_species_rels=Collect( + RelationNameResolver("coffees__species"), distinct=True + ), + ) + .all() + ) + assert len(result[0][1][0]) == 2 # 2 species must be there + assert len(result[0][2][0]) == 3 # 3 species relations must be there + @mark_sync_test def test_resolve_subgraph(): @@ -888,11 +902,11 @@ def test_intermediate_transform(): nescafe.species.connect(arabica) result = ( - Coffee.nodes.traverse_relations(suppliers="suppliers") + Coffee.nodes.fetch_relations("suppliers") .intermediate_transform( { "coffee": "coffee", - "suppliers": "suppliers", + "suppliers": NodeNameResolver("suppliers"), "r": RelationNameResolver("suppliers"), }, ordering=["-r.since"], @@ -915,6 +929,15 @@ def test_intermediate_transform(): "test": Collect("suppliers"), } ) + with raises( + ValueError, + match=re.escape( + r"You must provide one variable at least when calling intermediate_transform()" + ), + ): + Coffee.nodes.traverse_relations(suppliers="suppliers").intermediate_transform( + {} + ) @mark_sync_test