def test_multiple_edge_traversal_with_type_filtering(self): """ Tests that using multiple edges for traversals works """ v = TestModel.create(count=1, text='Test1') v1 = TestModel.create() TestEdge.create(v, v1) v2 = TestModel.create() OtherTestEdge.create(v, v2) v3 = TestModel.create() YetAnotherTestEdge.create(v, v3) v4 = OtherTestModel.create() TestEdge.create(v, v4) v5 = OtherTestModel.create() OtherTestEdge.create(v, v5) v6 = OtherTestModel.create() YetAnotherTestEdge.create(v, v6) assert len(v.outV()) == 6 assert len(v.outV(TestEdge, OtherTestEdge)) == 4 assert len(v.outV(TestEdge, OtherTestEdge, types=[TestModel])) == 2
def test_outgoing_edge_traversals(self): """Test that outgoing edge traversals work.""" e1 = TestEdge.create(self.v1, self.v2, numbers=12) e2 = TestEdge.create(self.v1, self.v3, numbers=13) e3 = OtherTestEdge.create(self.v2, self.v3, numbers=14) results = self.v2.outE() assert len(results) == 1 assert e3 in results results = self.v2.outE(types=[TestEdge]) assert len(results) == 0
def test_incoming_vertex_traversal(self): """Test that incoming vertex traversals work.""" e1 = TestEdge.create(self.v1, self.v2, numbers=12) e2 = TestEdge.create(self.v1, self.v3, numbers=13) e3 = TestEdge.create(self.v2, self.v3, numbers=14) results = self.v2.inV(TestEdge) assert len(results) == 1 assert self.v1 in results results = self.v2.inV(TestEdge, types=[OtherTestModel]) assert len(results) == 0
def test_incoming_edge_traversals(self): """Test that incoming edge traversals work.""" e1 = TestEdge.create(self.v1, self.v2, numbers=12) e2 = TestEdge.create(self.v1, self.v3, numbers=13) e3 = OtherTestEdge.create(self.v2, self.v3, numbers=14) results = self.v2.inE() assert len(results) == 1 assert e1 in results results = self.v2.inE(types=[OtherTestEdge]) assert len(results) == 0
def test_incoming_vertex_traversal(self): """Test that incoming vertex traversals work.""" e1 = TestEdge.create(self.v1, self.v2, numbers=12) e2 = TestEdge.create(self.v1, self.v3, numbers=13) e3 = TestEdge.create(self.v2, self.v3, numbers=14) results = self.v2.inV(TestEdge) assert len(results) == 1 assert self.v1 in results results = self.v2.inV(TestEdge, allowed_elements=[OtherTestModel]) assert len(results) == 0
def test_incoming_edge_traversals(self): """Test that incoming edge traversals work.""" e1 = TestEdge.create(self.v1, self.v2, numbers=12) e2 = TestEdge.create(self.v1, self.v3, numbers=13) e3 = OtherTestEdge.create(self.v2, self.v3, numbers=14) results = self.v2.inE() assert len(results) == 1 assert e1 in results results = self.v2.inE(allowed_elements=[OtherTestEdge]) assert len(results) == 0
def test_unknown_edge_traversal_filter_type_fails(self): """ Tests an exception is raised if a traversal filter is used that's not an edge class, instance or label string fails """ TestEdge.create(self.v1, self.v2) OtherTestEdge.create(self.v1, self.v3) YetAnotherTestEdge.create(self.v1, self.v4) with self.assertRaises(ThunderdomeException): out = self.v1.outV(5) with self.assertRaises(ThunderdomeException): out = self.v1.outV(True)
def test_outgoing_vertex_traversal(self): """Test that outgoing vertex traversals work.""" e1 = TestEdge.create(self.v1, self.v2, numbers=12) e2 = TestEdge.create(self.v1, self.v3, numbers=13) e3 = TestEdge.create(self.v2, self.v3, numbers=14) results = self.v1.outV(TestEdge) assert len(results) == 2 assert self.v2 in results assert self.v3 in results results = self.v1.outV(TestEdge, types=[OtherTestModel]) assert len(results) == 1 assert self.v3 in results
def test_edge_label_string_traversal_types(self): """ Test traversals with edge instances work properly """ TestEdge.create(self.v1, self.v2) OtherTestEdge.create(self.v1, self.v3) YetAnotherTestEdge.create(self.v1, self.v4) out = self.v1.outV(TestEdge.get_label(), OtherTestEdge.get_label()) assert len(out) == 2 assert self.v2.vid in [v.vid for v in out] assert self.v3.vid in [v.vid for v in out] out = self.v1.outV(OtherTestEdge.get_label(), YetAnotherTestEdge.get_label()) assert len(out) == 2 assert self.v3.vid in [v.vid for v in out] assert self.v4.vid in [v.vid for v in out]
def test_reload(self): """ Tests that the reload method performs an inplace update of an instance's values """ e1 = TestEdge.create(self.v1, self.v2, numbers=3) e2 = TestEdge.get_by_eid(e1.eid) e2.numbers = 5 e2.save() e1.reload() assert e1.numbers == 5
def test_model_deleting_works_properly(self): """q Tests that an instance's delete method deletes the instance """ e1 = TestEdge.create(self.v1, self.v2, numbers=3) e1.delete() edges = self.v1.outE() assert len(edges) == 0
def test_model_save_and_load(self): """ Tests that models can be saved and retrieved """ e1 = TestEdge.create(self.v1, self.v2, numbers=3) edges = self.v1.outE() assert len(edges) == 1 assert edges[0].eid == e1.eid
def test_model_updating_works_properly(self): """ Tests that subsequent saves after initial model creation work """ e1 = TestEdge.create(self.v1, self.v2, numbers=3) e1.numbers = 20 e1.save() edges = self.v1.outE() assert len(edges) == 1 assert edges[0].numbers == 20
def test_multiple_label_traversals(self): """ Tests that using multiple edges for traversals works """ TestEdge.create(self.v1, self.v2) OtherTestEdge.create(self.v1, self.v3) YetAnotherTestEdge.create(self.v1, self.v4) assert len(self.v1.outV()) == 3 assert len(self.v1.outV(TestEdge)) == 1 assert len(self.v1.outV(OtherTestEdge)) == 1 assert len(self.v1.outV(YetAnotherTestEdge)) == 1 out = self.v1.outV(TestEdge, OtherTestEdge) assert len(out) == 2 assert self.v2.vid in [v.vid for v in out] assert self.v3.vid in [v.vid for v in out] out = self.v1.outV(OtherTestEdge, YetAnotherTestEdge) assert len(out) == 2 assert self.v3.vid in [v.vid for v in out] assert self.v4.vid in [v.vid for v in out]
def test_edge_instance_traversal_types(self): """ Test traversals with edge instances work properly """ te = TestEdge.create(self.v1, self.v2) ote = OtherTestEdge.create(self.v1, self.v3) yate = YetAnotherTestEdge.create(self.v1, self.v4) out = self.v1.outV(te, ote) assert len(out) == 2 assert self.v2.vid in [v.vid for v in out] assert self.v3.vid in [v.vid for v in out] out = self.v1.outV(ote, yate) assert len(out) == 2 assert self.v3.vid in [v.vid for v in out] assert self.v4.vid in [v.vid for v in out]