1
1
import pytest
2
- from pandas import DataFrame
3
2
4
3
from .conftest import CollectingQueryRunner
5
4
from graphdatascience .graph_data_science import GraphDataScience
@@ -11,7 +10,7 @@ def test_all(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
11
10
G , _ = gds .graph .cypher .project ("g" )
12
11
13
12
assert G .name () == "g"
14
- assert runner .last_params () == dict ( graph_name = "g" )
13
+ assert runner .last_params () == { " graph_name" : "g" }
15
14
16
15
assert (
17
16
runner .last_query ()
@@ -25,7 +24,7 @@ def test_disconnected(runner: CollectingQueryRunner, gds: GraphDataScience) -> N
25
24
G , _ = gds .graph .cypher .project ("g" , allow_disconnected_nodes = True )
26
25
27
26
assert G .name () == "g"
28
- assert runner .last_params () == dict ( graph_name = "g" )
27
+ assert runner .last_params () == { " graph_name" : "g" }
29
28
30
29
assert (
31
30
runner .last_query ()
@@ -40,7 +39,7 @@ def test_inverse_graph(runner: CollectingQueryRunner, gds: GraphDataScience) ->
40
39
G , _ = gds .graph .cypher .project ("g" , inverse = True ) # TODO: or using orientation="INVERSE"?
41
40
42
41
assert G .name () == "g"
43
- assert runner .last_params () == dict ( graph_name = "g" )
42
+ assert runner .last_params () == { " graph_name" : "g" }
44
43
45
44
assert (
46
45
runner .last_query ()
@@ -54,9 +53,10 @@ def test_single_node_label(runner: CollectingQueryRunner, gds: GraphDataScience)
54
53
G , _ = gds .graph .cypher .project ("g" , nodes = "A" )
55
54
56
55
assert G .name () == "g"
57
- assert runner .last_params () == dict (
58
- graph_name = "g" , data_config = {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ]}
59
- )
56
+ assert runner .last_params () == {
57
+ "graph_name" : "g" ,
58
+ "data_config" : {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ]},
59
+ }
60
60
61
61
assert (
62
62
runner .last_query ()
@@ -70,9 +70,10 @@ def test_disconnected_nodes_single_node_label(runner: CollectingQueryRunner, gds
70
70
G , _ = gds .graph .cypher .project ("g" , nodes = "A" , allow_disconnected_nodes = True )
71
71
72
72
assert G .name () == "g"
73
- assert runner .last_params () == dict (
74
- graph_name = "g" , data_config = {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ]}
75
- )
73
+ assert runner .last_params () == {
74
+ "graph_name" : "g" ,
75
+ "data_config" : {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ]},
76
+ }
76
77
77
78
assert (
78
79
runner .last_query ()
@@ -84,12 +85,13 @@ def test_disconnected_nodes_single_node_label(runner: CollectingQueryRunner, gds
84
85
85
86
@pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 4 , 0 )])
86
87
def test_single_node_label_alias (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
87
- G , _ = gds .graph .cypher .project ("g" , nodes = dict ( Target = " Label") )
88
+ G , _ = gds .graph .cypher .project ("g" , nodes = { " Target" : " Label"} )
88
89
89
90
assert G .name () == "g"
90
- assert runner .last_params () == dict (
91
- graph_name = "g" , data_config = {"sourceNodeLabels" : ["Target" ], "targetNodeLabels" : ["Target" ]}
92
- )
91
+ assert runner .last_params () == {
92
+ "graph_name" : "g" ,
93
+ "data_config" : {"sourceNodeLabels" : ["Target" ], "targetNodeLabels" : ["Target" ]},
94
+ }
93
95
94
96
assert (
95
97
runner .last_query ()
@@ -103,9 +105,10 @@ def test_multiple_node_labels_and(runner: CollectingQueryRunner, gds: GraphDataS
103
105
G , _ = gds .graph .cypher .project ("g" , nodes = ["A" , "B" ], combine_labels_with = "AND" )
104
106
105
107
assert G .name () == "g"
106
- assert runner .last_params () == dict (
107
- graph_name = "g" , data_config = {"sourceNodeLabels" : ["A" , "B" ], "targetNodeLabels" : ["A" , "B" ]}
108
- )
108
+ assert runner .last_params () == {
109
+ "graph_name" : "g" ,
110
+ "data_config" : {"sourceNodeLabels" : ["A" , "B" ], "targetNodeLabels" : ["A" , "B" ]},
111
+ }
109
112
110
113
assert (
111
114
runner .last_query ()
@@ -119,9 +122,10 @@ def test_disconnected_nodes_multiple_node_labels_and(runner: CollectingQueryRunn
119
122
G , _ = gds .graph .cypher .project ("g" , nodes = ["A" , "B" ], combine_labels_with = "AND" , allow_disconnected_nodes = True )
120
123
121
124
assert G .name () == "g"
122
- assert runner .last_params () == dict (
123
- graph_name = "g" , data_config = {"sourceNodeLabels" : ["A" , "B" ], "targetNodeLabels" : ["A" , "B" ]}
124
- )
125
+ assert runner .last_params () == {
126
+ "graph_name" : "g" ,
127
+ "data_config" : {"sourceNodeLabels" : ["A" , "B" ], "targetNodeLabels" : ["A" , "B" ]},
128
+ }
125
129
126
130
assert (
127
131
runner .last_query ()
@@ -136,7 +140,7 @@ def test_multiple_node_labels_or(runner: CollectingQueryRunner, gds: GraphDataSc
136
140
G , _ = gds .graph .cypher .project ("g" , nodes = ["A" , "B" ], combine_labels_with = "OR" )
137
141
138
142
assert G .name () == "g"
139
- assert runner .last_params () == dict ( graph_name = "g" )
143
+ assert runner .last_params () == { " graph_name" : "g" }
140
144
141
145
assert runner .last_query () == (
142
146
"""MATCH (source)-->(target)
@@ -152,7 +156,7 @@ def test_disconnected_nodes_multiple_node_labels_or(runner: CollectingQueryRunne
152
156
G , _ = gds .graph .cypher .project ("g" , nodes = ["A" , "B" ], combine_labels_with = "OR" , allow_disconnected_nodes = True )
153
157
154
158
assert G .name () == "g"
155
- assert runner .last_params () == dict ( graph_name = "g" )
159
+ assert runner .last_params () == { " graph_name" : "g" }
156
160
157
161
assert runner .last_query () == (
158
162
"""MATCH (source)
@@ -170,10 +174,10 @@ def test_single_multi_graph(runner: CollectingQueryRunner, gds: GraphDataScience
170
174
G , _ = gds .graph .cypher .project ("g" , nodes = "A" , relationships = "REL" )
171
175
172
176
assert G .name () == "g"
173
- assert runner .last_params () == dict (
174
- graph_name = "g" ,
175
- data_config = {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ], "relationshipType" : "REL" },
176
- )
177
+ assert runner .last_params () == {
178
+ " graph_name" : "g" ,
179
+ " data_config" : {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ], "relationshipType" : "REL" },
180
+ }
177
181
178
182
assert (
179
183
runner .last_query ()
@@ -187,10 +191,10 @@ def test_disconnected_nodes_single_multi_graph(runner: CollectingQueryRunner, gd
187
191
G , _ = gds .graph .cypher .project ("g" , nodes = "A" , relationships = "REL" , allow_disconnected_nodes = True )
188
192
189
193
assert G .name () == "g"
190
- assert runner .last_params () == dict (
191
- graph_name = "g" ,
192
- data_config = {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ], "relationshipType" : "REL" },
193
- )
194
+ assert runner .last_params () == {
195
+ " graph_name" : "g" ,
196
+ " data_config" : {"sourceNodeLabels" : ["A" ], "targetNodeLabels" : ["A" ], "relationshipType" : "REL" },
197
+ }
194
198
195
199
assert (
196
200
runner .last_query ()
@@ -205,7 +209,7 @@ def test_multiple_multi_graph(runner: CollectingQueryRunner, gds: GraphDataScien
205
209
G , _ = gds .graph .cypher .project ("g" , nodes = ["A" , "B" ], relationships = ["REL1" , "REL2" ])
206
210
207
211
assert G .name () == "g"
208
- assert runner .last_params () == dict ( graph_name = "g" )
212
+ assert runner .last_params () == { " graph_name" : "g" }
209
213
210
214
assert (
211
215
runner .last_query ()
@@ -220,15 +224,12 @@ def test_multiple_multi_graph(runner: CollectingQueryRunner, gds: GraphDataScien
220
224
221
225
@pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 4 , 0 )])
222
226
def test_node_properties (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
223
- # G, _ = gds.graph.cypher.project(
224
- # "g", nodes=dict(L1=["prop1"], L2=["prop2", "prop3"], L3=dict(prop4=True, prop5=dict()))
225
- # )
226
227
G , _ = gds .graph .cypher .project (
227
228
"g" , nodes = {"L1" : ["prop1" ], "L2" : ["prop2" , "prop3" ], "L3" : {"prop4" : True , "prop5" : {}}}
228
229
)
229
230
230
231
assert G .name () == "g"
231
- assert runner .last_params () == dict ( graph_name = "g" )
232
+ assert runner .last_params () == { " graph_name" : "g" }
232
233
233
234
assert runner .last_query () == (
234
235
"""MATCH (source)-->(target)
@@ -256,11 +257,11 @@ def test_node_properties(runner: CollectingQueryRunner, gds: GraphDataScience) -
256
257
@pytest .mark .parametrize ("server_version" , [ServerVersion (2 , 4 , 0 )])
257
258
def test_node_properties_alias (runner : CollectingQueryRunner , gds : GraphDataScience ) -> None :
258
259
G , _ = gds .graph .cypher .project (
259
- "g" , nodes = dict ( A = dict ( target_prop1 = " source_prop1" , target_prop2 = dict ( property_key = " source_prop2")))
260
+ "g" , nodes = { "A" : { " target_prop1" : " source_prop1" , " target_prop2" : { " property_key" : " source_prop2"}}}
260
261
)
261
262
262
263
assert G .name () == "g"
263
- assert runner .last_params () == dict ( graph_name = "g" )
264
+ assert runner .last_params () == { " graph_name" : "g" }
264
265
265
266
assert runner .last_query () == (
266
267
"""MATCH (source:A)-->(target:A)
0 commit comments