class GraphTestCase(unittest.TestCase): def setUp(self): self.graph = Graph() def test_init(self): assert config.DATABASE_URL == self.graph.resource.db_url def test_V(self): vertices = self.graph.V vertices = list(vertices) assert len(vertices) > 0 def test_E(self): edges = self.graph.E edges = list(edges) assert len(edges) > 0 def test_idxV(self): self.graph.vertices.create({'name': 'james'}) vertices = self.graph.idxV(name="james") vertices = list(vertices) assert len(vertices) > 0 def test_idxE(self): self.james = self.graph.vertices.create({'name': 'James'}) self.julie = self.graph.vertices.create({'name': 'Julie'}) self.graph.edges.create(self.james, "test", self.julie, {'time': 'rightnow'}) edges = self.graph.idxE(time="rightnow") edges = list(edges) assert len(edges) > 0
class GraphTestCase(unittest.TestCase): def setUp(self): self.graph = Graph() def test_init(self): assert config.DATABASE_URL == self.graph.resource.db_url def test_V(self): vertices = self.graph.V vertices = list(vertices) assert len(vertices) > 0 def test_E(self): edges = self.graph.E edges = list(edges) assert len(edges) > 0 def test_idxV(self): self.graph.vertices.create({'name':'james'}) vertices = self.graph.idxV(name="james") vertices = list(vertices) assert len(vertices) > 0 def test_idxE(self): self.james = self.graph.vertices.create({'name':'James'}) self.julie = self.graph.vertices.create({'name':'Julie'}) self.graph.edges.create(self.james,"test",self.julie,{'time':'rightnow'}) edges = self.graph.idxE(time="rightnow") edges = list(edges) assert len(edges) > 0
def setUp(self): self.graph = Graph() self.james = self.graph.vertices.create({'name': 'James'}) self.julie = self.graph.vertices.create({'name': 'Julie'}) assert isinstance(self.james, Vertex) self.graph.edges.create(self.james, "test", self.julie) self.graph.edges.create(self.julie, "test", self.james)
def test_index(self): self.graph = Graph() index_name = "TEST" # need to fix this to accept actual data types in POST ikeys = '[name,location]' self.graph.indices.delete(index_name) i1 = self.graph.indices.create(index_name,"vertex","automatic",ikeys) assert i1.index_name == index_name assert i1.index_type == "automatic" james = self.graph.vertices.create({'name':'James'}) i1.put('name','James',james._id) i1.put('location','Dallas',james._id) results = i1.get('name','James') results = list(results) assert len(results) == 1 assert results[0].name == "James" total_size = i1.count('name','James') assert total_size == 1 keys = i1.keys() assert 'name' in keys assert 'location' in keys i2 = self.graph.indices.get(index_name) print "INDEX_NAME", index_name, i1.index_name, i2.index_name assert i1.index_name == i2.index_name i1.remove(james._id,'name','James') james = i1.get_unique('name','James') assert james is None results = i1.rebuild() assert type(results) == list self.graph.indices.delete(index_name)
def setUp(self): self.graph = Graph()
def setUp(self): self.graph = Graph() self.james = self.graph.vertices.create({'name': 'James'}) self.julie = self.graph.vertices.create({'name': 'Julie'})
class PartOf(Relation): label = "part_of" # note used because geometry to annotation: element_of class CreatedBy(Relationship): label = "created_by" creation_time = Property(Float, default="current_timestamp", nullable=False) @property def concept(self): return Concept.get(self.outV) @property def user(self): return User.get(self.inV) def current_timestamp(self): return time.time() if __name__ == '__main__': from bulbs.graph import Graph g = Graph() u = User(username="******", password="******")
"""Utilities to query the MindboggleDB """ ### currently all below is using generic bulbs framework from bulbs.graph import Graph from bulbs.model import Model # connect to mbdb g = Graph(db_url="http://localhost:8182/graphs/mindboggle") # create root node mb = g.vertices.create({ 'name': 'MindboggleDB', 'url': "http://localhost:8182/graphs/mindboggle" }) # create a project node def create_project(project): g.vertices.create({'name': project, 'label': 'Project'}) g.edges.create(mb, "has_project", proj) # create a subject node subj = g.vertices.create({'name': 'Subject1', 'label': 'Subject'}) g.edges.create(proj, "has_subject", subj) # create a basins node basins = g.vertices.create({'name': 'Basins', 'label': 'Basins'}) g.edges.create(subj, 'has_basins', basins)
from bulbs.graph import Graph from bulbs.element import Vertex from bulbs.datatype import Property, Integer, String class Person(Vertex): element_type = "person" name = Property(String, nullable=False) age = Property(Integer) def __init__(self, element=None, eid=None, **kwds): self.initialize(element, eid, kwds) james = Person(name="James", age=34) julie = Person(name="Julie", age=28) Graph().edges.create(james, "knows", julie)