def test_invalid_syntax_raises_cypher_error(graph): batch = WriteBatch(graph) batch.append(CypherJob("X")) try: batch.submit() except BatchError as error: assert isinstance(error, BatchError) cause = error.__cause__ assert isinstance(cause, GraphError) assert cause.__class__.__name__ == "SyntaxException" assert cause.exception == "SyntaxException" assert cause.fullname in [None, "org.neo4j.cypher.SyntaxException"] else: assert False
def test_complex_relate(self): alice, bob, carol, dave = self.graph.create( {"name": "Alice"}, {"name": "Bob"}, {"name": "Carol"}, {"name": "Dave"} ) batch = WriteBatch(self.graph) batch.get_or_create_path(alice, ("IS~MARRIED~TO", {"since": 1996}), bob) #batch.get_or_create((alice, "DISLIKES", carol, {"reasons": ["youth", "beauty"]})) batch.get_or_create_path(alice, ("DISLIKES!", {"reason": "youth"}), carol) rels1 = batch.submit() assert rels1 is not None assert len(rels1) == 2 batch = WriteBatch(self.graph) batch.get_or_create_path(bob, ("WORKS WITH", {"since": 2004, "company": "Megacorp"}), carol) #batch.get_or_create((alice, "DISLIKES", carol, {"reasons": ["youth", "beauty"]})) batch.get_or_create_path(alice, ("DISLIKES!", {"reason": "youth"}), carol) batch.get_or_create_path(bob, ("WORKS WITH", {"since": 2009, "company": "Megacorp"}), dave) rels2 = batch.submit() assert rels2 is not None assert len(rels2) == 3 assert rels1[1] == rels2[1]