MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test07_midfail

Method test07_midfail

tests/flow/test_foreach.py:288–314  ·  view source on GitHub ↗

mid-evaluation failure (memory free'd appropriately)

(self)

Source from the content-addressed store, hash-verified

286 [[1, 2], [2, 2], [3, 2], [4, 2]])
287
288 def test07_midfail(self):
289 """mid-evaluation failure (memory free'd appropriately)"""
290
291 # clean db
292 self.env.flush()
293 # Make a new graph object with no cache (problematic label info)
294 graph = Graph(self.env.getConnection(), GRAPH_ID)
295
296 try:
297 graph.query("FOREACH(i in [1, 2, 0, 3] | CREATE (n:N {v: 1/i}))")
298 except redis.exceptions.ResponseError as e:
299 self.env.assertIn("Division by zero", str(e))
300
301 # assure that no nodes are left (undo-log was applied correctly)
302 res = graph.query("MATCH (n) return count(n)")
303 self.env.assertEquals(res.result_set[0][0], 0)
304
305 # collect may not be used inside the list expression of FOREACH
306 try:
307 graph.query("""
308 MATCH (n:N)
309 FOREACH(n in collect(n) |
310 CREATE (m:M {v: n.v})
311 )"""
312 )
313 except redis.exceptions.ResponseError as e:
314 self.env.assertIn("Invalid use of aggregating function 'collect'", str(e))
315
316 def test08_complex(self):
317 """complicate things up"""

Callers

nothing calls this directly

Calls 3

GraphClass · 0.85
strFunction · 0.85
queryMethod · 0.45

Tested by

no test coverage detected