示例#1
0
 def test_node_hashing(self):
     g = Graph()
     node_1 = Node(g, 1234)
     node_2 = Node(g, 1234)
     node_3 = Node(g, 5678)
     self.assertEqual(hash(node_1), hash(node_2))
     self.assertNotEqual(hash(node_1), hash(node_3))
示例#2
0
 def test_node_equality(self):
     g = Graph()
     node_1 = Node(g, 1234)
     node_2 = Node(g, 1234)
     node_3 = Node(g, 5678)
     self.assertEqual(node_1, node_2)
     self.assertNotEqual(node_1, node_3)
     self.assertNotEqual(node_1, "this is not a node")
 def test_empty_node(self):
     g = Graph()
     a = Node(g, 1)
     r = cypher_repr(a, node_template="{labels} {properties}")
     self.assertEqual(u"({})", r)
示例#4
0
 def add_node(self, label, props):
     ''' Add a node to the graph. '''
     n = Node(label=label, properties=props)
     self.graph.add_node(n)
     return n