def test_can_create_relationship(self): a = Node("Person", name="Alice") b = Node("Person", name="Bob") r = Relationship(a, "KNOWS", b, since=1999) self.graph.create(r) assert remote(a) assert remote(b) assert remote(r) assert r.start_node() == a assert r.end_node() == b
def test_can_create_nodes_and_relationship(self): self.graph.delete_all() a = Node() b = Node() c = Node() ab = Relationship(a, "TO", b) bc = Relationship(b, "TO", c) ca = Relationship(c, "TO", a) self.graph.create(ab | bc | ca) assert remote(a) assert remote(b) assert remote(c) assert remote(ab) assert ab.start_node() == a assert ab.end_node() == b assert remote(bc) assert bc.start_node() == b assert bc.end_node() == c assert remote(ca) assert ca.start_node() == c assert ca.end_node() == a assert order(self.graph) == 3 assert size(self.graph) == 3
def test_construction_from_three_arguments(self): rel = Relationship(alice, "KNOWS", bob) assert rel.start_node() is alice assert rel.end_node() is bob assert rel.type() == "KNOWS"
def test_construction_from_node_and_type_arguments(self): rel = Relationship(alice, "LIKES") assert rel.start_node() is alice assert rel.end_node() is alice assert rel.type() == "LIKES"
def test_construction_from_one_argument(self): rel = Relationship(alice) assert rel.start_node() is alice assert rel.end_node() is alice assert rel.type() == "TO"