@@ -156,12 +156,12 @@ def test_can_run_simple_statement_with_params(self):
156
156
def test_fails_on_bad_syntax (self ):
157
157
session = GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session ()
158
158
with self .assertRaises (CypherError ):
159
- session .run ("X" ).discard ()
159
+ session .run ("X" ).consume ()
160
160
161
161
def test_fails_on_missing_parameter (self ):
162
162
session = GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session ()
163
163
with self .assertRaises (CypherError ):
164
- session .run ("RETURN {x}" ).discard ()
164
+ session .run ("RETURN {x}" ).consume ()
165
165
166
166
def test_can_run_simple_statement_from_bytes_string (self ):
167
167
session = GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session ()
@@ -227,7 +227,7 @@ def test_can_return_path(self):
227
227
def test_can_handle_cypher_error (self ):
228
228
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
229
229
with self .assertRaises (CypherError ):
230
- session .run ("X" ).discard ()
230
+ session .run ("X" ).consume ()
231
231
232
232
def test_keys_are_available_before_and_after_stream (self ):
233
233
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
@@ -248,30 +248,24 @@ class SummaryTestCase(ServerTestCase):
248
248
def test_can_obtain_summary_after_consuming_result (self ):
249
249
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
250
250
result = session .run ("CREATE (n) RETURN n" )
251
- list (result )
252
- summary = result .summary
251
+ summary = result .consume ()
253
252
assert summary .statement == "CREATE (n) RETURN n"
254
253
assert summary .parameters == {}
255
254
assert summary .statement_type == "rw"
256
255
assert summary .counters .nodes_created == 1
257
256
258
- def test_cannot_obtain_summary_without_consuming_result (self ):
259
- with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
260
- result = session .run ("CREATE (n) RETURN n" )
261
- assert result .summary is None
262
-
263
257
def test_no_plan_info (self ):
264
258
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
265
259
result = session .run ("CREATE (n) RETURN n" )
266
- list ( result ) # consume the result
267
- assert result . summary .plan is None
268
- assert result . summary .profile is None
260
+ summary = result . consume ()
261
+ assert summary .plan is None
262
+ assert summary .profile is None
269
263
270
264
def test_can_obtain_plan_info (self ):
271
265
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
272
266
result = session .run ("EXPLAIN CREATE (n) RETURN n" )
273
- list ( result ) # consume the result
274
- plan = result . summary .plan
267
+ summary = result . consume ()
268
+ plan = summary .plan
275
269
assert plan .operator_type == "ProduceResults"
276
270
assert plan .identifiers == ["n" ]
277
271
assert plan .arguments == {"planner" : "COST" , "EstimatedRows" : 1.0 , "version" : "CYPHER 3.0" ,
@@ -282,8 +276,8 @@ def test_can_obtain_plan_info(self):
282
276
def test_can_obtain_profile_info (self ):
283
277
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
284
278
result = session .run ("PROFILE CREATE (n) RETURN n" )
285
- list ( result ) # consume the result
286
- profile = result . summary .profile
279
+ summary = result . consume ()
280
+ profile = summary .profile
287
281
assert profile .db_hits == 0
288
282
assert profile .rows == 1
289
283
assert profile .operator_type == "ProduceResults"
@@ -296,19 +290,19 @@ def test_can_obtain_profile_info(self):
296
290
def test_no_notification_info (self ):
297
291
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
298
292
result = session .run ("CREATE (n) RETURN n" )
299
- list ( result ) # consume the result
300
- notifications = result . summary .notifications
293
+ summary = result . consume ()
294
+ notifications = summary .notifications
301
295
assert notifications == []
302
296
303
297
def test_can_obtain_notification_info (self ):
304
298
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
305
299
result = session .run ("EXPLAIN MATCH (n), (m) RETURN n, m" )
306
- list ( result ) # consume the result
307
- notifications = result . summary .notifications
300
+ summary = result . consume ()
301
+ notifications = summary .notifications
308
302
309
303
assert len (notifications ) == 1
310
304
notification = notifications [0 ]
311
- assert notification .code == "Neo.ClientNotification.Statement.CartesianProduct "
305
+ assert notification .code == "Neo.ClientNotification.Statement.CartesianProductWarning "
312
306
assert notification .title == "This query builds a cartesian product between " \
313
307
"disconnected patterns."
314
308
assert notification .severity == "WARNING"
@@ -333,7 +327,7 @@ class ResetTestCase(ServerTestCase):
333
327
def test_automatic_reset_after_failure (self ):
334
328
with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
335
329
try :
336
- session .run ("X" ).discard ()
330
+ session .run ("X" ).consume ()
337
331
except CypherError :
338
332
result = session .run ("RETURN 1" )
339
333
record = next (result )
@@ -347,7 +341,7 @@ def test_defunct(self):
347
341
assert not session .connection .defunct
348
342
with patch .object (ChunkChannel , "chunk_reader" , side_effect = ProtocolError ()):
349
343
with self .assertRaises (ProtocolError ):
350
- session .run ("RETURN 1" ).discard ()
344
+ session .run ("RETURN 1" ).consume ()
351
345
assert session .connection .defunct
352
346
assert session .connection .closed
353
347
0 commit comments