@@ -89,36 +89,36 @@ def test_can_run_statement_that_returns_multiple_records(self):
8989
9090 def test_can_use_with_to_auto_close_session (self ):
9191 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
92- records = session .run ("RETURN 1" )
93- assert len (records ) == 1
94- for record in records :
92+ result = session .run ("RETURN 1" )
93+ assert len (result ) == 1
94+ for record in result :
9595 assert record [0 ] == 1
9696
9797 def test_can_return_node (self ):
9898 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
99- records = session .run ("MERGE (a:Person {name:'Alice'}) RETURN a" )
100- assert len (records ) == 1
101- for record in records :
99+ result = session .run ("MERGE (a:Person {name:'Alice'}) RETURN a" )
100+ assert len (result ) == 1
101+ for record in result :
102102 alice = record [0 ]
103103 assert isinstance (alice , Node )
104104 assert alice .labels == {"Person" }
105105 assert alice .properties == {"name" : "Alice" }
106106
107107 def test_can_return_relationship (self ):
108108 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
109- records = session .run ("MERGE ()-[r:KNOWS {since:1999}]->() RETURN r" )
110- assert len (records ) == 1
111- for record in records :
109+ result = session .run ("MERGE ()-[r:KNOWS {since:1999}]->() RETURN r" )
110+ assert len (result ) == 1
111+ for record in result :
112112 rel = record [0 ]
113113 assert isinstance (rel , Relationship )
114114 assert rel .type == "KNOWS"
115115 assert rel .properties == {"since" : 1999 }
116116
117117 def test_can_return_path (self ):
118118 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
119- records = session .run ("MERGE p=({name:'Alice'})-[:KNOWS]->({name:'Bob'}) RETURN p" )
120- assert len (records ) == 1
121- for record in records :
119+ result = session .run ("MERGE p=({name:'Alice'})-[:KNOWS]->({name:'Bob'}) RETURN p" )
120+ assert len (result ) == 1
121+ for record in result :
122122 path = record [0 ]
123123 assert isinstance (path , Path )
124124 assert path .start .properties == {"name" : "Alice" }
@@ -138,9 +138,18 @@ def test_can_handle_cypher_error(self):
138138
139139 def test_record_equality (self ):
140140 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
141- records = session .run ("unwind([1, 1]) AS a RETURN a" )
142- assert records [0 ] == records [1 ]
143- assert records [0 ] != "this is not a record"
141+ result = session .run ("unwind([1, 1]) AS a RETURN a" )
142+ assert result [0 ] == result [1 ]
143+ assert result [0 ] != "this is not a record"
144+
145+ def test_can_obtain_summary_info (self ):
146+ with GraphDatabase .driver ("bolt://localhost" ).session () as session :
147+ result = session .run ("CREATE (n) RETURN n" )
148+ summary = result .summarize ()
149+ assert summary .statement == "CREATE (n) RETURN n"
150+ assert summary .parameters == {}
151+ assert summary .statement_type == "rw"
152+ assert summary .statistics .nodes_created == 1
144153
145154
146155class TransactionTestCase (TestCase ):
@@ -150,8 +159,8 @@ def test_can_commit_transaction(self):
150159 tx = session .new_transaction ()
151160
152161 # Create a node
153- records = tx .run ("CREATE (a) RETURN id(a)" )
154- node_id = records [0 ][0 ]
162+ result = tx .run ("CREATE (a) RETURN id(a)" )
163+ node_id = result [0 ][0 ]
155164 assert isinstance (node_id , int )
156165
157166 # Update a property
@@ -161,18 +170,18 @@ def test_can_commit_transaction(self):
161170 tx .commit ()
162171
163172 # Check the property value
164- records = session .run ("MATCH (a) WHERE id(a) = {n} "
173+ result = session .run ("MATCH (a) WHERE id(a) = {n} "
165174 "RETURN a.foo" , {"n" : node_id })
166- foo = records [0 ][0 ]
175+ foo = result [0 ][0 ]
167176 assert foo == "bar"
168177
169178 def test_can_rollback_transaction (self ):
170179 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
171180 tx = session .new_transaction ()
172181
173182 # Create a node
174- records = tx .run ("CREATE (a) RETURN id(a)" )
175- node_id = records [0 ][0 ]
183+ result = tx .run ("CREATE (a) RETURN id(a)" )
184+ node_id = result [0 ][0 ]
176185 assert isinstance (node_id , int )
177186
178187 # Update a property
@@ -182,17 +191,17 @@ def test_can_rollback_transaction(self):
182191 tx .rollback ()
183192
184193 # Check the property value
185- records = session .run ("MATCH (a) WHERE id(a) = {n} "
194+ result = session .run ("MATCH (a) WHERE id(a) = {n} "
186195 "RETURN a.foo" , {"n" : node_id })
187- assert len (records ) == 0
196+ assert len (result ) == 0
188197
189198 def test_can_commit_transaction_using_with_block (self ):
190199 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
191200 with session .new_transaction () as tx :
192201
193202 # Create a node
194- records = tx .run ("CREATE (a) RETURN id(a)" )
195- node_id = records [0 ][0 ]
203+ result = tx .run ("CREATE (a) RETURN id(a)" )
204+ node_id = result [0 ][0 ]
196205 assert isinstance (node_id , int )
197206
198207 # Update a property
@@ -202,28 +211,28 @@ def test_can_commit_transaction_using_with_block(self):
202211 tx .success = True
203212
204213 # Check the property value
205- records = session .run ("MATCH (a) WHERE id(a) = {n} "
214+ result = session .run ("MATCH (a) WHERE id(a) = {n} "
206215 "RETURN a.foo" , {"n" : node_id })
207- foo = records [0 ][0 ]
216+ foo = result [0 ][0 ]
208217 assert foo == "bar"
209218
210219 def test_can_rollback_transaction_using_with_block (self ):
211220 with GraphDatabase .driver ("bolt://localhost" ).session () as session :
212221 with session .new_transaction () as tx :
213222
214223 # Create a node
215- records = tx .run ("CREATE (a) RETURN id(a)" )
216- node_id = records [0 ][0 ]
224+ result = tx .run ("CREATE (a) RETURN id(a)" )
225+ node_id = result [0 ][0 ]
217226 assert isinstance (node_id , int )
218227
219228 # Update a property
220229 tx .run ("MATCH (a) WHERE id(a) = {n} "
221230 "SET a.foo = {foo}" , {"n" : node_id , "foo" : "bar" })
222231
223232 # Check the property value
224- records = session .run ("MATCH (a) WHERE id(a) = {n} "
233+ result = session .run ("MATCH (a) WHERE id(a) = {n} "
225234 "RETURN a.foo" , {"n" : node_id })
226- assert len (records ) == 0
235+ assert len (result ) == 0
227236
228237
229238if __name__ == "__main__" :
0 commit comments