99from graphdatascience .query_runner .arrow_query_runner import ArrowQueryRunner
1010from graphdatascience .query_runner .query_runner import QueryRunner
1111from graphdatascience .server_version .server_version import ServerVersion
12- from graphdatascience .tests .integration .conftest import AUTH , DB , URI
12+ from graphdatascience .tests .integration .conftest import AUTH , DB , URI , is_neo4j_44
1313
1414GRAPH_NAME = "g"
1515
@@ -56,7 +56,7 @@ def test_project_graph_cypher(gds: GraphDataScience) -> None:
5656 node_query = "MATCH (n:Node) RETURN id(n) as id"
5757 relationship_query = "MATCH (n:Node)-->(m:Node) RETURN id(n) as source, id(m) as target, 'T' as type"
5858
59- if gds .server_version () >= ServerVersion (2 , 4 , 0 ):
59+ if gds .server_version () >= ServerVersion (2 , 4 , 0 ) and not is_neo4j_44 ( gds ) :
6060 with pytest .warns (DeprecationWarning ):
6161 G , result = gds .graph .project .cypher (GRAPH_NAME , node_query , relationship_query )
6262 else :
@@ -73,7 +73,7 @@ def test_project_graph_cypher_estimate(gds: GraphDataScience) -> None:
7373 node_query = "MATCH (n:Node) RETURN id(n) as id"
7474 relationship_query = "MATCH (n:Node)-->(m:Node) RETURN id(n) as source, id(m) as target, 'T' as type"
7575
76- if gds .server_version () >= ServerVersion (2 , 5 , 0 ):
76+ if gds .server_version () >= ServerVersion (2 , 5 , 0 ) and not is_neo4j_44 ( gds ) :
7777 with pytest .warns (DeprecationWarning ):
7878 result = gds .graph .project .cypher .estimate (node_query , relationship_query )
7979 else :
@@ -103,7 +103,7 @@ def test_cypher_projection_empty_graph(gds: GraphDataScience) -> None:
103103def test_beta_project_subgraph (runner : QueryRunner , gds : GraphDataScience ) -> None :
104104 from_G , _ = gds .graph .project (GRAPH_NAME , {"Node" : {"properties" : "x" }}, "*" )
105105
106- if gds .server_version () >= ServerVersion (2 , 5 , 0 ):
106+ if gds .server_version () >= ServerVersion (2 , 5 , 0 ) and not is_neo4j_44 ( gds ) :
107107 with pytest .warns (DeprecationWarning ):
108108 sub_G , result = gds .beta .graph .project .subgraph ("s" , from_G , "n.x > 1" , "*" , concurrency = 2 )
109109 else :
@@ -153,7 +153,7 @@ def test_sample_rwr(runner: QueryRunner, gds: GraphDataScience) -> None:
153153def test_sample_rwr_alpha (runner : QueryRunner , gds : GraphDataScience ) -> None :
154154 from_G , _ = gds .graph .project (GRAPH_NAME , {"Node" : {"properties" : "x" }}, "*" )
155155
156- if gds .server_version () >= ServerVersion (2 , 4 , 0 ):
156+ if gds .server_version () >= ServerVersion (2 , 4 , 0 ) and not is_neo4j_44 ( gds ) :
157157 with pytest .warns (DeprecationWarning ):
158158 rwr_G , result = gds .alpha .graph .sample .rwr ("s" , from_G , samplingRatio = 0.6 , concurrency = 1 , randomSeed = 42 )
159159 else :
@@ -267,7 +267,7 @@ def test_graph_export(runner: QueryRunner, gds: GraphDataScience) -> None:
267267def test_beta_graph_export_csv_estimate (gds : GraphDataScience ) -> None :
268268 G , _ = gds .graph .project (GRAPH_NAME , "*" , "*" )
269269
270- if gds .server_version () >= ServerVersion (2 , 5 , 0 ):
270+ if gds .server_version () >= ServerVersion (2 , 5 , 0 ) and not is_neo4j_44 ( gds ) :
271271 with pytest .warns (DeprecationWarning ):
272272 result = gds .beta .graph .export .csv .estimate (G , exportName = "dummy" )
273273 else :
@@ -338,6 +338,9 @@ def test_graph_nodeProperty_stream_with_arrow_no_db() -> None:
338338def test_graph_streamNodeProperty_without_arrow (gds_without_arrow : GraphDataScience ) -> None :
339339 G , _ = gds_without_arrow .graph .project (GRAPH_NAME , {"Node" : {"properties" : "x" }}, "*" )
340340
341+ if is_neo4j_44 (gds_without_arrow ):
342+ return
343+
341344 with pytest .warns (DeprecationWarning ):
342345 result = gds_without_arrow .graph .streamNodeProperty (G , "x" , concurrency = 2 )
343346
@@ -518,6 +521,9 @@ def test_graph_nodeProperties_stream_raise_error_with_duplicate_keys(gds: GraphD
518521def test_graph_streamNodeProperties_without_arrow (gds_without_arrow : GraphDataScience ) -> None :
519522 G , _ = gds_without_arrow .graph .project (GRAPH_NAME , {"Node" : {"properties" : ["x" , "y" ]}}, "*" )
520523
524+ if is_neo4j_44 (gds_without_arrow ):
525+ return
526+
521527 with pytest .warns (DeprecationWarning ):
522528 result = gds_without_arrow .graph .streamNodeProperties (G , ["x" , "y" ], concurrency = 2 )
523529
@@ -561,6 +567,9 @@ def test_graph_nodeProperties_stream_without_arrow(gds_without_arrow: GraphDataS
561567def test_graph_nodeProperties_fail_on_duplicate_node_properties (gds : GraphDataScience ) -> None :
562568 G , _ = gds .graph .project (GRAPH_NAME , {"Node" : {"properties" : ["x" , "y" ]}}, "*" )
563569
570+ if is_neo4j_44 (gds ):
571+ return
572+
564573 with pytest .raises (ValueError , match = "The provided node_properties contain duplicate property names" ):
565574 gds .graph .nodeProperties .stream (G , ["x" , "x" , "y" ], db_node_properties = ["z" , "name" ], concurrency = 2 )
566575
@@ -573,6 +582,9 @@ def test_graph_streamNodeProperties_without_arrow_separate_property_columns(
573582) -> None :
574583 G , _ = gds_without_arrow .graph .project (GRAPH_NAME , {"Node" : {"properties" : ["x" , "z" ]}}, "*" )
575584
585+ if is_neo4j_44 (gds_without_arrow ):
586+ return
587+
576588 with pytest .warns (DeprecationWarning ):
577589 result = gds_without_arrow .graph .streamNodeProperties (
578590 G , ["x" , "z" ], separate_property_columns = True , concurrency = 2
@@ -626,6 +638,9 @@ def test_graph_relationshipProperty_stream_with_arrow(gds: GraphDataScience) ->
626638def test_graph_streamRelationshipProperty_without_arrow (gds_without_arrow : GraphDataScience ) -> None :
627639 G , _ = gds_without_arrow .graph .project (GRAPH_NAME , "*" , {"REL" : {"properties" : "relX" }})
628640
641+ if is_neo4j_44 (gds_without_arrow ):
642+ return
643+
629644 with pytest .warns (DeprecationWarning ):
630645 result = gds_without_arrow .graph .streamRelationshipProperty (G , "relX" , concurrency = 2 )
631646 assert {e for e in result ["propertyValue" ]} == {4 , 5 , 6 }
@@ -746,6 +761,9 @@ def test_graph_relationshipProperties_stream_with_arrow_rel_as_str_sep(gds: Grap
746761def test_graph_streamRelationshipProperties_without_arrow (gds_without_arrow : GraphDataScience ) -> None :
747762 G , _ = gds_without_arrow .graph .project (GRAPH_NAME , "*" , {"REL" : {"properties" : ["relX" , "relY" ]}})
748763
764+ if is_neo4j_44 (gds_without_arrow ):
765+ return
766+
749767 with pytest .warns (DeprecationWarning ):
750768 result = gds_without_arrow .graph .streamRelationshipProperties (G , ["relX" , "relY" ], concurrency = 2 )
751769
@@ -787,6 +805,8 @@ def test_graph_streamRelationshipProperties_without_arrow_separate_property_colu
787805 gds_without_arrow : GraphDataScience ,
788806) -> None :
789807 G , _ = gds_without_arrow .graph .project (GRAPH_NAME , "*" , {"REL" : {"properties" : ["relX" , "relY" ]}})
808+ if is_neo4j_44 (gds_without_arrow ):
809+ return
790810
791811 with pytest .warns (DeprecationWarning ):
792812 result = gds_without_arrow .graph .streamRelationshipProperties (
@@ -863,7 +883,7 @@ def test_graph_relationships_stream_with_arrow(gds: GraphDataScience) -> None:
863883 else :
864884 result = gds .beta .graph .relationships .stream (G , ["REL" , "REL2" ])
865885
866- with pytest . warns ( DeprecationWarning ) :
886+ def workload () -> None :
867887 expected = gds .run_cypher ("MATCH (n)-[r]->(m) RETURN id(n) AS src_id, id(m) AS trg_id, type(r) AS rel_type" )
868888
869889 assert list (result .keys ()) == ["sourceNodeId" , "targetNodeId" , "relationshipType" ]
@@ -872,6 +892,12 @@ def test_graph_relationships_stream_with_arrow(gds: GraphDataScience) -> None:
872892 for _ , row in expected .iterrows ():
873893 assert (result == np .array (row )).all (1 ).any ()
874894
895+ if is_neo4j_44 (gds ):
896+ workload ()
897+ else :
898+ with pytest .warns (DeprecationWarning ):
899+ workload ()
900+
875901 by_rel_type = result .by_rel_type ()
876902
877903 num_rels = 0
@@ -888,7 +914,7 @@ def test_graph_relationships_stream_with_arrow(gds: GraphDataScience) -> None:
888914def test_beta_graph_relationships_to_undirected (gds : GraphDataScience ) -> None :
889915 G , _ = gds .graph .project (GRAPH_NAME , "Node" , ["REL" , "REL2" ])
890916
891- if gds .server_version () >= ServerVersion (2 , 5 , 0 ):
917+ if gds .server_version () >= ServerVersion (2 , 5 , 0 ) and not is_neo4j_44 ( gds ) :
892918 with pytest .warns (DeprecationWarning ):
893919 result = gds .beta .graph .relationships .toUndirected (G , "REL" , "REL_UNDIRECTED" )
894920 else :
@@ -912,8 +938,12 @@ def test_graph_writeNodeProperties(gds: GraphDataScience) -> None:
912938
913939 gds .pageRank .mutate (G , mutateProperty = "rank" , dampingFactor = 0.2 , tolerance = 0.3 )
914940
915- with pytest . warns ( DeprecationWarning ):
941+ if is_neo4j_44 ( gds ):
916942 result = gds .graph .writeNodeProperties (G , ["rank" ], concurrency = 2 )
943+ else :
944+ with pytest .warns (DeprecationWarning ):
945+ result = gds .graph .writeNodeProperties (G , ["rank" ], concurrency = 2 )
946+
917947 assert result ["propertiesWritten" ] == 3
918948
919949
@@ -922,8 +952,12 @@ def test_graph_writeRelationship(gds: GraphDataScience) -> None:
922952
923953 gds .nodeSimilarity .mutate (G , mutateRelationshipType = "SIMILAR" , mutateProperty = "score" , similarityCutoff = 0 )
924954
925- with pytest . warns ( DeprecationWarning ):
955+ if is_neo4j_44 ( gds ):
926956 result = gds .graph .writeRelationship (G , "SIMILAR" , "score" , concurrency = 2 )
957+ else :
958+ with pytest .warns (DeprecationWarning ):
959+ result = gds .graph .writeRelationship (G , "SIMILAR" , "score" , concurrency = 2 )
960+
927961 assert result ["relationshipsWritten" ] == 2
928962 assert result ["propertiesWritten" ] == 2
929963
@@ -978,8 +1012,12 @@ def test_graph_nodeLabel_mutate(gds: GraphDataScience) -> None:
9781012def test_graph_removeNodeProperties_21 (gds : GraphDataScience ) -> None :
9791013 G , _ = gds .graph .project (GRAPH_NAME , {"Node" : {"properties" : "x" }}, "*" )
9801014
981- with pytest . warns ( DeprecationWarning ):
1015+ if is_neo4j_44 ( gds ):
9821016 result = gds .graph .removeNodeProperties (G , ["x" ], concurrency = 2 )
1017+ else :
1018+ with pytest .warns (DeprecationWarning ):
1019+ result = gds .graph .removeNodeProperties (G , ["x" ], concurrency = 2 )
1020+
9831021 assert result ["propertiesRemoved" ] == 3
9841022
9851023
@@ -1003,8 +1041,11 @@ def test_graph_removeNodeProperties_20(gds: GraphDataScience) -> None:
10031041def test_graph_deleteRelationships (gds : GraphDataScience ) -> None :
10041042 G , _ = gds .graph .project (GRAPH_NAME , "*" , ["REL" , "REL2" ])
10051043
1006- with pytest . warns ( DeprecationWarning ):
1044+ if is_neo4j_44 ( gds ):
10071045 result = gds .graph .deleteRelationships (G , "REL" )
1046+ else :
1047+ with pytest .warns (DeprecationWarning ):
1048+ result = gds .graph .deleteRelationships (G , "REL" )
10081049 assert result ["deletedRelationships" ] == 3
10091050
10101051
@@ -1017,7 +1058,7 @@ def test_graph_relationships_drop(gds: GraphDataScience) -> None:
10171058
10181059
10191060def test_beta_graph_generate (gds : GraphDataScience ) -> None :
1020- if gds .server_version () >= ServerVersion (2 , 5 , 0 ):
1061+ if gds .server_version () >= ServerVersion (2 , 5 , 0 ) and not is_neo4j_44 ( gds ) :
10211062 with pytest .warns (DeprecationWarning ):
10221063 G , result = gds .beta .graph .generate (GRAPH_NAME , 12 , 2 )
10231064 else :
0 commit comments