Exemple #1
0
 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]