def setUp(self): indices = self.vertex_index_proxy(self.index_class, self.resource) self.people = NodeProxy(Person, self.resource) self.knows = RelationshipProxy(Knows, self.resource) self.people.index = indices.get_or_create("people") self.james = self.people.create(name="James", age=34) self.julie = self.people.create(name="Julie", age=28)
class NodeTestCase(BulbsTestCase): def setUp(self): indices = self.vertex_index_proxy(self.index_class, self.client) self.people = NodeProxy(Person, self.client) self.people.index = indices.get_or_create("person") self.james = self.people.create(name="James", age=34, is_adult=True) def test_properties(self): #assert type(self.james.eid) == int assert self.james.element_type == "person" assert self.james.name == "James" assert self.james.age == 34 assert self.james.is_adult is True def test_get(self): person = self.people.get(self.james.eid) assert person == self.james def test_get_all(self): people = self.people.get_all() assert len(list(people)) > 1 def test_index_name(self): index_name = self.people.index.index_name assert index_name == "person"
class NodeTestCase(BulbsTestCase): def setUp(self): indices = self.vertex_index_proxy(self.index_class,self.client) self.people = NodeProxy(Person,self.client) self.people.index = indices.get_or_create("person") self.james = self.people.create(name="James", age=34, is_adult=True) def test_properties(self): #assert type(self.james.eid) == int assert self.james.element_type == "person" assert self.james.name == "James" assert self.james.age == 34 assert self.james.is_adult is True def test_get(self): person = self.people.get(self.james.eid) assert person == self.james def test_get_all(self): people = self.people.get_all() assert len(list(people)) > 1 def test_index_name(self): index_name = self.people.index.index_name assert index_name == "person"
def setUp(self): indicesV = self.vertex_index_proxy(self.index_class, self.client) indicesE = self.edge_index_proxy(self.index_class, self.client) self.people = NodeProxy(Person, self.client) self.people.index = indicesV.get_or_create("people") self.knows = RelationshipProxy(Knows, self.client) self.knows.index = indicesE.get_or_create("knows") self.james = self.people.create(name="James", age=34) self.julie = self.people.create(name="Julie", age=28)
def setUp(self): indices = self.vertex_index_proxy(self.index_class,self.resource) self.people = NodeProxy(Person,self.resource) self.knows = RelationshipProxy(Knows,self.resource) self.people.index = indices.get_or_create("people") self.james = self.people.create(name="James", age=34) self.julie = self.people.create(name="Julie", age=28)
def create(self, _data=None, **kwds): # TODO: Convert asserts to appropriate exceptions from dagcuss import dynagraph is_root = (_data and "root" in _data and _data["root"]) or ("root" in kwds and kwds["root"]) if _data and "parents" in data: parents = _data["parents"] del _data["parents"] elif "parents" in kwds: parents = kwds["parents"] del kwds["parents"] else: # Root has no parents assert is_root parents = [] if is_root: # Only one root assert len(list(graph.posts.index.lookup(root=1))) == 0 post = NodeProxy.create(self, _data, **kwds) replies = [] for parent in parents: replies.append(graph.replies.create(parent, post)) dynagraph.client( insert_node=(post.eid,), insert_edge=tuple( {"id": reply.eid, "from_id": reply.outV().eid, "to_id": reply.inV().eid} for reply in replies ), ) return post
def create(self, _data=None, **kwds): # TODO: Convert asserts to appropriate exceptions from dagcuss import dynagraph is_root = ((_data and 'root' in _data and _data['root']) or ('root' in kwds and kwds['root'])) if _data and 'parents' in data: parents = _data['parents'] del _data['parents'] elif 'parents' in kwds: parents = kwds['parents'] del kwds['parents'] else: # Root has no parents assert is_root parents = [] if is_root: # Only one root assert len(list(graph.posts.index.lookup(root=1))) == 0 post = NodeProxy.create(self, _data, **kwds) replies = [] for parent in parents: replies.append(graph.replies.create(parent, post)) dynagraph.client(insert_node=(post.eid, ), insert_edge=tuple({ 'id': reply.eid, 'from_id': reply.outV().eid, 'to_id': reply.inV().eid, } for reply in replies)) return post
class RelationshipTestCase(BulbsTestCase): def setUp(self): indices = self.vertex_index_proxy(self.index_class, self.resource) self.people = NodeProxy(Person, self.resource) self.knows = RelationshipProxy(Knows, self.resource) self.people.index = indices.get_or_create("people") self.james = self.people.create(name="James", age=34) self.julie = self.people.create(name="Julie", age=28) #self.relationship = Relationship.create(self.james,"knows",self.julie) def test_properties(self): self.relationship = self.knows.create(self.james, self.julie) assert self.relationship._label == "knows" assert self.relationship.outV()._id == self.james.eid assert self.relationship.inV()._id == self.julie.eid
class RelationshipTestCase(BulbsTestCase): def setUp(self): indices = self.vertex_index_proxy(self.index_class,self.client) self.people = NodeProxy(Person,self.client) self.knows = RelationshipProxy(Knows,self.client) self.people.index = indices.get_or_create("people") self.james = self.people.create(name="James", age=34) self.julie = self.people.create(name="Julie", age=28) def test_properties(self): self.relationship = self.knows.create(self.james,self.julie) assert self.relationship._label == "knows" assert self.relationship.outV()._id == self.james.eid assert self.relationship.inV()._id == self.julie.eid
def setUp(self): indices = self.vertex_index_proxy(self.index_class, self.client) self.people = NodeProxy(Person, self.client) self.people.index = indices.get_or_create("person") self.james = self.people.create(name="James", age=34)