Exemple #1
0
class IndexTestCase(BulbsTestCase):
    def setUp(self):
        self.indicesV = self.vertex_index_proxy(self.index_class, self.client)
        self.indicesE = self.edge_index_proxy(self.index_class, self.client)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")

        self.vertices = VertexProxy(Vertex, self.client)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge, self.client)
        self.edges.index = self.indicesE.get_or_create("test_idxE")

    def test_index(self):
        index_name = "test_idxV"
        # need to fix this to accept actual data types in POST
        ikeys = '[name,location]'
        james = self.vertices.create({'name': 'James'})
        self.vertices.index.put(james._id, 'name', 'James')
        self.vertices.index.put(james._id, 'location', 'Dallas')
        results = self.vertices.index.lookup('name', 'James')
        results = list(results)
        assert len(results) == 1
        assert results[0].name == "James"

        total_size = self.vertices.index.count('name', 'James')
        assert total_size == 1
        i2 = self.indicesV.get(index_name)
        assert self.vertices.index.index_name == i2.index_name

        self.vertices.index.remove(james._id, 'name', 'James')
        james = self.vertices.index.get_unique('name', 'James')
        assert james is None

        self.indicesV.delete(index_name)

    def test_ascii_encoding_index_lookup(self):
        # Fixed for Neo4j Server. Still having issues with Rexster...
        # https://github.com/espeed/bulbs/issues/117
        # using default index name because that's what create_indexed_vertex() uses
        name = u'Aname M\xf6ller' + bulbs.utils.to_string(random.random())
        index_name = Vertex.get_index_name(self.vertices.client.config)
        self.vertices.client.config.set_logger(ERROR)
        self.vertices.index = self.indicesV.get_or_create(index_name)
        v1a = self.vertices.create(name=name)
        v1b = self.vertices.index.lookup(u"name", name)
        assert next(v1b).name == name

    def test_ascii_encoding_index_lookup2(self):
        # http://stackoverflow.com/questions/23057915/rexster-bulbs-unicode-node-property-node-created-but-not-found
        # using default index name because that's what create_indexed_vertex() uses
        name = u'Université de Montréal' + bulbs.utils.to_string(
            random.random())
        index_name = Vertex.get_index_name(self.vertices.client.config)
        self.vertices.client.config.set_logger(ERROR)
        self.vertices.index = self.indicesV.get_or_create(index_name)
        v1a = self.vertices.create(name=name)
        v1b = self.vertices.index.lookup(u"name", name)
        assert next(v1b).name == name
Exemple #2
0
 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)
Exemple #3
0
class IndexTestCase(BulbsTestCase):
    def setUp(self):
        self.indicesV = self.vertex_index_proxy(self.index_class, self.client)
        self.indicesE = self.edge_index_proxy(self.index_class, self.client)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")

        self.vertices = VertexProxy(Vertex, self.client)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge, self.client)
        self.edges.index = self.indicesE.get_or_create("test_idxE")

    def test_index(self):
        index_name = "test_idxV"
        # need to fix this to accept actual data types in POST
        ikeys = "[name,location]"
        james = self.vertices.create({"name": "James"})
        self.vertices.index.put(james._id, "name", "James")
        self.vertices.index.put(james._id, "location", "Dallas")
        results = self.vertices.index.lookup("name", "James")
        results = list(results)
        assert len(results) == 1
        assert results[0].name == "James"

        total_size = self.vertices.index.count("name", "James")
        assert total_size == 1
        i2 = self.indicesV.get(index_name)
        assert self.vertices.index.index_name == i2.index_name

        self.vertices.index.remove(james._id, "name", "James")
        james = self.vertices.index.get_unique("name", "James")
        assert james is None

        self.indicesV.delete(index_name)

    def test_ascii_encoding_index_lookup(self):
        # Fixed for Neo4j Server. Still having issues with Rexster...
        # https://github.com/espeed/bulbs/issues/117
        # using default index name because that's what create_indexed_vertex() uses
        name = u"Aname M\xf6ller" + bulbs.utils.to_string(random.random())
        index_name = Vertex.get_index_name(self.vertices.client.config)
        self.vertices.client.config.set_logger(ERROR)
        self.vertices.index = self.indicesV.get_or_create(index_name)
        v1a = self.vertices.create(name=name)
        v1b = self.vertices.index.lookup(u"name", name)
        assert next(v1b).name == name

    def test_ascii_encoding_index_lookup2(self):
        # http://stackoverflow.com/questions/23057915/rexster-bulbs-unicode-node-property-node-created-but-not-found
        # using default index name because that's what create_indexed_vertex() uses
        name = u"Université de Montréal" + bulbs.utils.to_string(random.random())
        index_name = Vertex.get_index_name(self.vertices.client.config)
        self.vertices.client.config.set_logger(ERROR)
        self.vertices.index = self.indicesV.get_or_create(index_name)
        v1a = self.vertices.create(name=name)
        v1b = self.vertices.index.lookup(u"name", name)
        assert next(v1b).name == name
 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'})
     assert isinstance(self.james,Vertex)
     self.edges.create(self.james,"test",self.julie)
     self.edges.create(self.julie,"test",self.james)
Exemple #5
0
    def setUp(self):
        self.indicesV = VertexIndexProxy(self.index_class, self.client)
        self.indicesE = EdgeIndexProxy(self.index_class, self.client)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")

        self.vertices = VertexProxy(Vertex, self.client)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge, self.client)
        self.edges.index = self.indicesE.get_or_create("test_idxE")
Exemple #6
0
    def setUp(self):

        self.indicesV = VertexIndexProxy(self.index_class,self.resource)
        self.indicesE = EdgeIndexProxy(self.index_class,self.resource)

        #self.indicesV.delete("edges")
        #self.indicesE.delete("edges")

        self.vertices = VertexProxy(Vertex,self.resource)
        self.vertices.index = self.indicesV.get_or_create("vertices")

        self.edges = EdgeProxy(Edge,self.resource)
        self.edges.index = self.indicesE.get_or_create("edges")
Exemple #7
0
class VertexProxyTestCase(BulbsTestCase):
    def setUp(self):
        self.vertices = VertexProxy(Vertex, self.client)

    def test_create(self):
        james = self.vertices.create({'name': 'James'})
        assert isinstance(james, Vertex)
        #assert type(james._id) == int
        assert james._type == "vertex"
        assert james.name == "James"

    def test_update_and_get(self):
        james1 = self.vertices.create({'name': 'James'})
        self.vertices.update(james1._id, {'name': 'James', 'age': 34})
        james2 = self.vertices.get(james1._id)
        assert james2._id == james1._id
        assert james2.name == "James"
        assert james2.age == 34

    #def test_get_all(self):
    #   vertices = self.vertices.get_all()
    #    vertices = list(vertices)
    #    assert len(vertices) > 0

    #def test_remove_property(self):
    #    query_time = self.vertices.remove(self.james._id,'age')
    #    assert type(query_time) == float
    #    assert self.james.age is None

    def test_delete_vertex(self):
        james = self.vertices.create({'name': 'James'})
        resp = self.vertices.delete(james._id)
        j2 = self.vertices.get(james._id)
        assert j2 == None
Exemple #8
0
class IndexTestCase(BulbsTestCase):
    
    def setUp(self):
        self.indicesV = self.vertex_index_proxy(self.index_class,self.client)
        self.indicesE = self.edge_index_proxy(self.index_class,self.client)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")
        
        self.vertices = VertexProxy(Vertex,self.client)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge,self.client)
        self.edges.index = self.indicesE.get_or_create("test_idxE")
               
    def test_index(self):
        index_name = "test_idxV"
        # need to fix this to accept actual data types in POST
        ikeys = '[name,location]'
        james = self.vertices.create({'name':'James'})
        self.vertices.index.put(james._id,'name','James')
        self.vertices.index.put(james._id,'location','Dallas')
        results = self.vertices.index.lookup('name','James')
        results = list(results)
        assert len(results) == 1
        assert results[0].name == "James"
        
        total_size = self.vertices.index.count('name','James')
        assert total_size == 1
        i2 = self.indicesV.get(index_name)
        assert self.vertices.index.index_name == i2.index_name
        
        self.vertices.index.remove(james._id,'name','James')
        james = self.vertices.index.get_unique('name','James')
        assert james is None
  
        self.indicesV.delete(index_name)

    def test_ascii_encoding_index_lookup(self):
        # Fixed for Neo4j Server. Still having issues with Rexster...
        # https://github.com/espeed/bulbs/issues/117
        # using default index name because that's what create_indexed_vertex() uses
        name = u'Aname M\xf6ller' + bulbs.utils.to_string(random.random())
        index_name = Vertex.get_index_name(self.vertices.client.config)
        self.vertices.client.config.set_logger(ERROR)
        self.vertices.index = self.indicesV.get_or_create(index_name)
        v1a = self.vertices.create(name=name)
        v1b = self.vertices.index.lookup(u"name", name)
        assert next(v1b).name == name
Exemple #9
0
 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)
Exemple #10
0
class IndexTestCase(BulbsTestCase):
    
    def setUp(self):

        self.indicesV = VertexIndexProxy(self.index_class,self.resource)
        self.indicesE = EdgeIndexProxy(self.index_class,self.resource)

        #self.indicesV.delete("edges")
        #self.indicesE.delete("edges")

        self.vertices = VertexProxy(Vertex,self.resource)
        self.vertices.index = self.indicesV.get_or_create("vertices")

        self.edges = EdgeProxy(Edge,self.resource)
        self.edges.index = self.indicesE.get_or_create("edges")
               
    def test_index(self):
        index_name = "vertices"
        #index_name = "TEST"
        # need to fix this to accept actual data types in POST
        ikeys = '[name,location]'
        #self.indicesV.delete(index_name)
        #i1 = self.indicesV.create(index_name)
        #assert i1.index_name == index_name
        #assert i1.index_type == "automatic"
        #print self.vertices.index.index_type
        assert self.vertices.index.index_type == "exact"

        james = self.vertices.create({'name':'James'})
        self.vertices.index.put(james._id,'name','James')
        self.vertices.index.put(james._id,'location','Dallas')
        results = self.vertices.index.lookup('name','James')
        results = list(results)
        #print "RESULTS", results
        assert len(results) > 1
        assert results[0].name == "James"
        total_size = self.vertices.index.count('name','James')
        assert total_size > 1
        # NOTE: only automatic indicesV have user provided keys
        #keys = i1.keys()
        #assert 'name' in keys
        #assert 'location' in keys
        i2 = self.indicesV.get(index_name)
        #print "INDEX_NAME", index_name, i1.index_name, i2.index_name
        assert self.vertices.index.index_name == i2.index_name
        
        # remove vertex is bugged
        #i1.remove(james._id,'name','James')
        #james = i1.get_unique('name','James')
        #assert james is None
  
        # only can rebuild automatic indices
        #i3 = self.indicesV.get("vertices")
        #results = i3.rebuild()
        #assert type(results) == list

        self.indicesV.delete(index_name)
Exemple #11
0
    def __init__(self, root_uri=SAIL_URI):
        self.config = Config(root_uri)
        self.resource = RexsterResource(self.config)

        # No indices on sail graphs
        self.gremlin = Gremlin(self.resource)

        self.vertices = VertexProxy(Vertex, self.resource)
        self.edges = EdgeProxy(Edge, self.resource)
Exemple #12
0
class IndexTestCase(BulbsTestCase):
    
    def setUp(self):
        self.indicesV = self.vertex_index_proxy(self.index_class,self.resource)
        self.indicesE = self.edge_index_proxy(self.index_class,self.resource)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")

        self.vertices = VertexProxy(Vertex,self.resource)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge,self.resource)
        self.edges.index = self.indicesE.get_or_create("test_idxE")
               
    def test_index(self):
        index_name = "test_idxV"
        #index_name = "TEST"
        # need to fix this to accept actual data types in POST
        ikeys = '[name,location]'
        #self.indicesV.delete(index_name)
        #i1 = self.indicesV.create(index_name)
        #assert i1.index_name == index_name
        #assert i1.index_type == "automatic"
        #print self.vertices.index.index_type
        #assert self.vertices.index.index_type == "exact"

        james = self.vertices.create({'name':'James'})
        self.vertices.index.put(james._id,'name','James')
        self.vertices.index.put(james._id,'location','Dallas')
        results = self.vertices.index.get('name','James')
        results = list(results)
        #print "RESULTS", results
        assert len(results) == 1
        assert results[0].name == "James"
        total_size = self.vertices.index.count('name','James')
        #print "TOTAL SIZE", total_size
        assert total_size == 1
        # NOTE: only automatic indicesV have user provided keys
        #keys = i1.keys()
        #assert 'name' in keys
        #assert 'location' in keys
        i2 = self.indicesV.get(index_name)
        #print "INDEX_NAME", index_name, self.vertices.index.index_name, i2.index_name
        assert self.vertices.index.index_name == i2.index_name
        
        # remove vertex is bugged
        #i1.remove(james._id,'name','James')
        #james = i1.get_unique('name','James')
        #assert james is None
  
        # only can rebuild automatic indices
        #i3 = self.indicesV.get("vertices")
        #results = i3.rebuild()
        #assert type(results) == list

        self.indicesV.delete(index_name)
Exemple #13
0
class VertexProxyTestCase(BulbsTestCase):

    def setUp(self):
        self.vertices = VertexProxy(Vertex,self.client)

    def test_create(self):
        james = self.vertices.create({'name':'James'})
        assert isinstance(james,Vertex)
        #assert type(james._id) == int
        assert james._type == "vertex"
        assert james.name == "James"

    def test_update_and_get(self):
        james1 = self.vertices.create({'name':'James'})
        self.vertices.update(james1._id, {'name':'James','age':34})
        james2 = self.vertices.get(james1._id)
        assert james2._id == james1._id
        assert james2.name == "James"
        assert james2.age == 34


    #def test_get_all(self):
     #   vertices = self.vertices.get_all()
    #    vertices = list(vertices)
    #    assert len(vertices) > 0

    #def test_remove_property(self):
    #    query_time = self.vertices.remove(self.james._id,'age')
    #    assert type(query_time) == float
    #    assert self.james.age is None

    def test_delete_vertex(self):
        james = self.vertices.create({'name':'James'})
        resp = self.vertices.delete(james._id)
        j2 = self.vertices.get(james._id)
        assert j2 == None

    def test_ascii_encoding(self):
        # http://stackoverflow.com/questions/19824952/unicodeencodeerror-bulbs-and-neo4j-create-model
        data = {u'name': u'Aname M\xf6ller'}
        v1a = self.vertices.create(data)
        v1b = self.vertices.get(v1a._id)
        assert v1b.name == data['name']
Exemple #14
0
class VertexProxyTestCase(BulbsTestCase):

    def setUp(self):
        self.vertices = VertexProxy(Vertex,self.client)

    def test_create(self):
        james = self.vertices.create({'name':'James'})
        assert isinstance(james,Vertex)
        #assert type(james._id) == int
        assert james._type == "vertex"
        assert james.name == "James"

    def test_update_and_get(self):
        james1 = self.vertices.create({'name':'James'})
        self.vertices.update(james1._id, {'name':'James','age':34})
        james2 = self.vertices.get(james1._id)
        assert james2._id == james1._id
        assert james2.name == "James"
        assert james2.age == 34


    #def test_get_all(self):
     #   vertices = self.vertices.get_all()
    #    vertices = list(vertices)
    #    assert len(vertices) > 0

    #def test_remove_property(self):
    #    query_time = self.vertices.remove(self.james._id,'age')
    #    assert type(query_time) == float
    #    assert self.james.age is None

    def test_delete_vertex(self):
        james = self.vertices.create({'name':'James'})
        resp = self.vertices.delete(james._id)
        j2 = self.vertices.get(james._id)
        assert j2 == None

    def test_ascii_encoding(self):
        # http://stackoverflow.com/questions/19824952/unicodeencodeerror-bulbs-and-neo4j-create-model
        data = {u'name': u'Aname M\xf6ller'}
        v1a = self.vertices.create(data)
        v1b = self.vertices.get(v1a._id)
        assert v1b.name == data['name']
Exemple #15
0
    def __init__(self, root_uri=REXSTER_URI):
        self.config = Config(root_uri)
        self.resource = RexsterResource(self.config)

        self.gremlin = Gremlin(self.resource)
        self.indices = IndexProxy(RexsterIndex, resource)

        self.vertices = VertexProxy(Vertex, self.resource)
        self.vertices.index = self.indices.get("vertices", Vertex)

        self.edges = EdgeProxy(Edge, self.resource)
        self.edges.index = self.indices.get("edges", Edge)
Exemple #16
0
    def setUp(self):
        self.indicesV = VertexIndexProxy(self.index_class, self.resource)
        self.indicesE = EdgeIndexProxy(self.index_class, self.resource)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")

        self.vertices = VertexProxy(Vertex, self.resource)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge, self.resource)
        self.edges.index = self.indicesE.get_or_create("test_idxE")
Exemple #17
0
    def setUp(self):
        self.indicesV = self.vertex_index_proxy(self.index_class,self.client)
        self.indicesE = self.edge_index_proxy(self.index_class,self.client)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")
        
        self.vertices = VertexProxy(Vertex,self.client)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge,self.client)
        self.edges.index = self.indicesE.get_or_create("test_idxE")
Exemple #18
0
    def __init__(self, root_uri=NEO4J_URI):
        self.config = Config(root_uri)
        self.resource = Neo4jResource(self.config)

        self.gremlin = Gremlin(self.resource)

        self.indicesV = VertexIndexProxy(ExactIndex, self.resource)
        self.indicesE = EdgeIndexProxy(ExactIndex, self.resource)

        # What happens if these REST calls error on Heroku?

        self.vertices = VertexProxy(Vertex, self.resource)
        self.vertices.index = self.indicesV.get_or_create("vertices")

        self.edges = EdgeProxy(Edge, self.resource)
        self.edges.index = self.indicesE.get_or_create("edges")
Exemple #19
0
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
Exemple #20
0
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
Exemple #21
0
class IndexTestCase(BulbsTestCase):
    
    def setUp(self):
        self.vertices = VertexProxy(Vertex,self.resource)
        self.indices = IndexProxy(self.index_class,self.resource)
       
    def test_index(self):
        index_name = "TEST"
        # need to fix this to accept actual data types in POST
        ikeys = '[name,location]'
        self.indices.delete(index_name)
        i1 = self.indices.create(index_name,Vertex)
        assert i1.index_name == index_name
        assert i1.index_type == "automatic"
        james = self.vertices.create({'name':'James'})
        i1.put(james._id,'name','James')
        i1.put(james._id,'location','Dallas')
        results = i1.get('name','James')
        results = list(results)
        print "RESULTS", results
        assert len(results) == 1
        assert results[0].name == "James"
        total_size = i1.count('name','James')
        assert total_size == 1
        # NOTE: only automatic indices have user provided keys
        #keys = i1.keys()
        #assert 'name' in keys
        #assert 'location' in keys
        i2 = self.indices.get(index_name,Vertex)
        print "INDEX_NAME", index_name, i1.index_name, i2.index_name
        assert i1.index_name == i2.index_name
        
        # remove vertex is bugged
        #i1.remove(james._id,'name','James')
        #james = i1.get_unique('name','James')
        #assert james is None
  
        # only can rebuild automatic indices
        i3 = self.indices.get("vertices",Vertex)
        results = i3.rebuild()
        assert type(results) == list

        self.indices.delete(index_name)
Exemple #22
0
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 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
Exemple #24
0
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
Exemple #25
0
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
Exemple #26
0
class VertexProxyTestCase(BulbsTestCase):

    def setUp(self):
        self.vertices = VertexProxy(Vertex,self.client)

    def test_create(self):
        james = self.vertices.create({'name':'James'})
        assert isinstance(james,Vertex)
        #assert type(james._id) == int
        assert james._type == "vertex"
        assert james.name == "James"

    def test_update_and_get(self):
        james1 = self.vertices.create({'name':'James'})
        self.vertices.update(james1._id, {'name':'James','age':34})
        james2 = self.vertices.get(james1._id)
        assert james2._id == james1._id
        assert james2.name == "James"
        assert james2.age == 34


    #def test_get_all(self):
     #   vertices = self.vertices.get_all()
    #    vertices = list(vertices)
    #    assert len(vertices) > 0

    #def test_remove_property(self):
    #    query_time = self.vertices.remove(self.james._id,'age')
    #    assert type(query_time) == float
    #    assert self.james.age is None

    def test_delete_vertex(self):
        james = self.vertices.create({'name':'James'})
        resp = self.vertices.delete(james._id)
        j2 = self.vertices.get(james._id)
        assert j2 == None
Exemple #27
0
class IndexTestCase(BulbsTestCase):
    
    def setUp(self):
        self.indicesV = self.vertex_index_proxy(self.index_class,self.client)
        self.indicesE = self.edge_index_proxy(self.index_class,self.client)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")

        self.vertices = VertexProxy(Vertex,self.client)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge,self.client)
        self.edges.index = self.indicesE.get_or_create("test_idxE")
               
    def test_index(self):
        index_name = "test_idxV"
        # need to fix this to accept actual data types in POST
        ikeys = '[name,location]'
        james = self.vertices.create({'name':'James'})
        self.vertices.index.put(james._id,'name','James')
        self.vertices.index.put(james._id,'location','Dallas')
        results = self.vertices.index.lookup('name','James')
        results = list(results)
        assert len(results) == 1
        assert results[0].name == "James"
        
        total_size = self.vertices.index.count('name','James')
        assert total_size == 1
        i2 = self.indicesV.get(index_name)
        assert self.vertices.index.index_name == i2.index_name
        
        self.vertices.index.remove(james._id,'name','James')
        james = self.vertices.index.get_unique('name','James')
        assert james is None
  
        self.indicesV.delete(index_name)
Exemple #28
0
class IndexTestCase(BulbsTestCase):
    def setUp(self):
        self.indicesV = self.vertex_index_proxy(self.index_class, self.client)
        self.indicesE = self.edge_index_proxy(self.index_class, self.client)

        self.indicesV.delete("test_idxV")
        self.indicesE.delete("test_idxE")

        self.vertices = VertexProxy(Vertex, self.client)
        self.vertices.index = self.indicesV.get_or_create("test_idxV")

        self.edges = EdgeProxy(Edge, self.client)
        self.edges.index = self.indicesE.get_or_create("test_idxE")

    def test_index(self):
        index_name = "test_idxV"
        # need to fix this to accept actual data types in POST
        ikeys = '[name,location]'
        james = self.vertices.create({'name': 'James'})
        self.vertices.index.put(james._id, 'name', 'James')
        self.vertices.index.put(james._id, 'location', 'Dallas')
        results = self.vertices.index.lookup('name', 'James')
        results = list(results)
        assert len(results) == 1
        assert results[0].name == "James"

        total_size = self.vertices.index.count('name', 'James')
        assert total_size == 1
        i2 = self.indicesV.get(index_name)
        assert self.vertices.index.index_name == i2.index_name

        self.vertices.index.remove(james._id, 'name', 'James')
        james = self.vertices.index.get_unique('name', 'James')
        assert james is None

        self.indicesV.delete(index_name)
Exemple #29
0
 def setUp(self):
     self.vertices = VertexProxy(Vertex,self.resource)
     self.indices = IndexProxy(self.index_class,self.resource)
 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'})
Exemple #31
0
 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'})
Exemple #32
0
 def setUp(self):
     self.vertices = VertexProxy(Vertex, self.client)
Exemple #33
0
 def setUp(self):
     self.vertices = VertexProxy(Vertex,self.client)
 def setUp(self):
     self.vertices = VertexProxy(Vertex,self.resource)
Exemple #35
0
 def setUp(self):
     self.vertices = VertexProxy(Vertex,self.resource)