本文整理汇总了Python中bulbs.element.VertexProxy类的典型用法代码示例。如果您正苦于以下问题:Python VertexProxy类的具体用法?Python VertexProxy怎么用?Python VertexProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VertexProxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IndexTestCase
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
示例2: IndexTestCase
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
示例3: setUp
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)
示例4: IndexTestCase
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)
示例5: VertexProxyTestCase
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']
示例6: setUp
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")
示例7: setUp
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")
示例8: EdgeProxyTestCase
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
示例9: IndexTestCase
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)
示例10: EdgeProxyTestCase
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
示例11: VertexTestCase
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
示例12: VertexProxyTestCase
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
示例13: IndexTestCase
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)
示例14: setUp
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'})
示例15: setUp
def setUp(self):
self.vertices = VertexProxy(Vertex,self.resource)
self.indices = IndexProxy(self.index_class,self.resource)