コード例 #1
0
 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
コード例 #2
0
 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
コード例 #3
0
 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"
コード例 #4
0
 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"
コード例 #5
0
 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"