Ejemplo n.º 1
0
 def test_can_create_relationship(self):
     alice = Node({"Person"}, {"name": "Alice", "age": 33})
     bob = Node({"Person"}, {"name": "Bob", "age": 44})
     alice_knows_bob = Relationship(alice, bob, "KNOWS", {"since": 1999})
     assert alice_knows_bob.start is alice
     assert alice_knows_bob.type == "KNOWS"
     assert alice_knows_bob.end is bob
     assert set(alice_knows_bob.keys()) == {"since"}
     assert set(alice_knows_bob.values()) == {1999}
     assert set(alice_knows_bob.items()) == {("since", 1999)}
     assert alice_knows_bob.get("since") == 1999
     assert repr(alice_knows_bob)
Ejemplo n.º 2
0
 def test_can_hydrate_path(self):
     alice = Node({"Person"}, {"name": "Alice", "age": 33})
     bob = Node({"Person"}, {"name": "Bob", "age": 44})
     carol = Node({"Person"}, {"name": "Carol", "age": 55})
     alice_knows_bob = Relationship(alice, bob, "KNOWS", {"since": 1999})
     carol_dislikes_bob = Relationship(carol, bob, "DISLIKES")
     path = Path.hydrate([alice, bob, carol],
                         [alice_knows_bob.unbind(), carol_dislikes_bob.unbind()],
                         [1, 1, -2, 2])
     assert path.start == alice
     assert path.end == carol
     assert path.nodes == (alice, bob, carol)
     assert path.relationships == (alice_knows_bob, carol_dislikes_bob)
     assert list(path) == [alice_knows_bob, carol_dislikes_bob]
     assert repr(path)