def test_graph_references(self): graph = ObjectGraph() n1 = graph.createNode(Node, "n1") n2 = graph.createNode(Node, "n2") graph.createReference(None, n1, None) graph.createReference(None, n2, "hello") self.assertEqual(graph.edgeData(None, n1), None) self.assertEqual(graph.edgeData(None, n2), "hello") graph.updateEdgeData(None, n1, "world") self.assertEqual(graph.edgeData(None, n1), "world") out, inc = graph.get_edges(None) out = list(out) inc = list(inc) self.assertEqual(out, [n1, n2]) self.assertEqual(len(out), 2) self.assertTrue(n1 in out) self.assertTrue(n2 in out) self.assertEqual(inc, []) graph.removeReference(None, n2) out, inc = graph.get_edges(None) out = list(out) inc = list(inc) self.assertTrue(n2 not in out)
def test_edge_data(self): graph = ObjectGraph() n1 = graph.createNode(ArgNode, "n1", 1) n2 = graph.createNode(ArgNode, "n2", 2) n3 = graph.createNode(ArgNode, "n3", 3) graph.createReference(n1, n2) graph.createReference(n1, n3, "foo") self.assertIs(graph.edgeData(n1, n2), None) self.assertIs(graph.edgeData(n1, n3), "foo") graph.updateEdgeData(n1, n2, "bar") self.assertIs(graph.edgeData(n1, n2), "bar")