@@ -156,12 +156,12 @@ def test_can_run_simple_statement_with_params(self):
156156 def test_fails_on_bad_syntax (self ):
157157 session = GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session ()
158158 with self .assertRaises (CypherError ):
159- session .run ("X" ).discard ()
159+ session .run ("X" ).consume ()
160160
161161 def test_fails_on_missing_parameter (self ):
162162 session = GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session ()
163163 with self .assertRaises (CypherError ):
164- session .run ("RETURN {x}" ).discard ()
164+ session .run ("RETURN {x}" ).consume ()
165165
166166 def test_can_run_simple_statement_from_bytes_string (self ):
167167 session = GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session ()
@@ -227,7 +227,7 @@ def test_can_return_path(self):
227227 def test_can_handle_cypher_error (self ):
228228 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
229229 with self .assertRaises (CypherError ):
230- session .run ("X" ).discard ()
230+ session .run ("X" ).consume ()
231231
232232 def test_keys_are_available_before_and_after_stream (self ):
233233 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
@@ -248,30 +248,24 @@ class SummaryTestCase(ServerTestCase):
248248 def test_can_obtain_summary_after_consuming_result (self ):
249249 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
250250 result = session .run ("CREATE (n) RETURN n" )
251- list (result )
252- summary = result .summary
251+ summary = result .consume ()
253252 assert summary .statement == "CREATE (n) RETURN n"
254253 assert summary .parameters == {}
255254 assert summary .statement_type == "rw"
256255 assert summary .counters .nodes_created == 1
257256
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-
263257 def test_no_plan_info (self ):
264258 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
265259 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
269263
270264 def test_can_obtain_plan_info (self ):
271265 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
272266 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
275269 assert plan .operator_type == "ProduceResults"
276270 assert plan .identifiers == ["n" ]
277271 assert plan .arguments == {"planner" : "COST" , "EstimatedRows" : 1.0 , "version" : "CYPHER 3.0" ,
@@ -282,8 +276,8 @@ def test_can_obtain_plan_info(self):
282276 def test_can_obtain_profile_info (self ):
283277 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
284278 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
287281 assert profile .db_hits == 0
288282 assert profile .rows == 1
289283 assert profile .operator_type == "ProduceResults"
@@ -296,19 +290,19 @@ def test_can_obtain_profile_info(self):
296290 def test_no_notification_info (self ):
297291 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
298292 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
301295 assert notifications == []
302296
303297 def test_can_obtain_notification_info (self ):
304298 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
305299 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
308302
309303 assert len (notifications ) == 1
310304 notification = notifications [0 ]
311- assert notification .code == "Neo.ClientNotification.Statement.CartesianProduct "
305+ assert notification .code == "Neo.ClientNotification.Statement.CartesianProductWarning "
312306 assert notification .title == "This query builds a cartesian product between " \
313307 "disconnected patterns."
314308 assert notification .severity == "WARNING"
@@ -333,7 +327,7 @@ class ResetTestCase(ServerTestCase):
333327 def test_automatic_reset_after_failure (self ):
334328 with GraphDatabase .driver ("bolt://localhost" , auth = auth_token ).session () as session :
335329 try :
336- session .run ("X" ).discard ()
330+ session .run ("X" ).consume ()
337331 except CypherError :
338332 result = session .run ("RETURN 1" )
339333 record = next (result )
@@ -347,7 +341,7 @@ def test_defunct(self):
347341 assert not session .connection .defunct
348342 with patch .object (ChunkChannel , "chunk_reader" , side_effect = ProtocolError ()):
349343 with self .assertRaises (ProtocolError ):
350- session .run ("RETURN 1" ).discard ()
344+ session .run ("RETURN 1" ).consume ()
351345 assert session .connection .defunct
352346 assert session .connection .closed
353347
0 commit comments