예제 #1
0
 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)
예제 #2
0
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"
예제 #3
0
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"
예제 #4
0
    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)
예제 #5
0
 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)
예제 #6
0
파일: models.py 프로젝트: frankier/dagcuss
    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
예제 #7
0
 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
예제 #8
0
    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)
예제 #9
0
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
예제 #10
0
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
예제 #11
0
 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)
예제 #12
0
 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)