class EdgeProxyTestCase(BulbsTestCase): def setUp(self): self.vertices = VertexProxy(Vertex,self.client) self.edges = EdgeProxy(Edge,self.client) self.james = self.vertices.create({'name':'James'}) self.julie = self.vertices.create({'name':'Julie'}) def test_create(self): data = dict(timestamp=int(time.time())) edge = self.edges.create(self.james, "test", self.julie, data) assert edge._outV == self.james._id assert edge._label == "test" assert edge._inV == self.julie._id def test_update_and_get(self): now = int(time.time()) e1 = self.edges.create(self.james,"test",self.julie, {'timestamp': now}) assert e1.timestamp == now later = int(time.time()) self.edges.update(e1._id, {'timestamp': later}) e2 = self.edges.get(e1._id) assert e1._id == e2._id assert e1._inV == e2._inV assert e1._label == e2._label assert e1._outV == e2._outV assert e2.timestamp == later #def test_get_all(self): # edges = self.edges.get_all() # edges = list(edges) # assert type(edges) == list #def test_remove_property(self): # e1 = self.edges.create(self.james,"test",self.julie,{'time':'today'}) # query_time = self.edges.remove(e1._id,{'time'}) # assert type(query_time) == float # assert e1.time is None def test_delete_edge(self): e1 = self.edges.create(self.james,"test",self.julie) resp = self.edges.delete(e1._id) e2 = self.edges.get(e1._id) assert e2 == None
class EdgeProxyTestCase(BulbsTestCase): def setUp(self): self.vertices = VertexProxy(Vertex,self.resource) self.edges = EdgeProxy(Edge,self.resource) self.james = self.vertices.create({'name':'James'}) self.julie = self.vertices.create({'name':'Julie'}) def test_create(self): edge = self.edges.create(self.james,"test",self.julie) assert edge._outV == self.james._id assert edge._label == "test" assert edge._inV == self.julie._id def test_update_and_get(self): e1 = self.edges.create(self.james,"test",self.julie,{'time':'today'}) assert e1.time == 'today' self.edges.update(e1._id,{'time':'tomorrow'}) e2 = self.edges.get(e1._id) assert e1._id == e2._id assert e1._inV == e2._inV assert e1._label == e2._label assert e1._outV == e2._outV assert e2.time == 'tomorrow' #def test_get_all(self): # edges = self.edges.get_all() # edges = list(edges) # assert type(edges) == list #def test_remove_property(self): # e1 = self.edges.create(self.james,"test",self.julie,{'time':'today'}) # query_time = self.edges.remove(e1._id,{'time'}) # assert type(query_time) == float # assert e1.time is None def test_delete_edge(self): e1 = self.edges.create(self.james,"test",self.julie) resp = self.edges.delete(e1._id) e2 = self.edges.get(e1._id) assert e2 == None
class VertexTestCase(BulbsTestCase): def setUp(self): self.vertices = VertexProxy(Vertex,self.client) self.edges = EdgeProxy(Edge,self.client) self.james = self.vertices.create({'name':'James'}) self.julie = self.vertices.create({'name':'Julie'}) self.edges.create(self.james,"test",self.julie) self.edges.create(self.julie,"test",self.james) def test_init(self): #assert type(self.james._id) == int assert isinstance(self.james,Vertex) assert self.james._type == "vertex" assert self.james.name == "James" assert self.julie._type == "vertex" assert self.julie.name == "Julie" def test_get_out_edges(self): edges = self.james.outE() edges = list(edges) assert len(edges) == 1 def test_get_in_edges(self): edges = self.james.inE() edges = list(edges) assert len(edges) == 1 def test_get_both_edges(self): edges = self.james.bothE() edges = list(edges) assert len(edges) == 2 def test_get_both_labeled_edges(self): edges = self.james.bothE("test") edges = list(edges) assert len(edges) == 2