def test_suite(): # pass in a db_name to test a specific database client = RexsterClient(db_name=db_name) BulbsTestCase.client = client BulbsTestCase.vertex_index_proxy = VertexIndexProxy BulbsTestCase.edge_index_proxy = EdgeIndexProxy BulbsTestCase.index_class = ManualIndex BulbsTestCase.graph = Graph(client.config) suite = bulbs_test_suite() #suite.addTest(unittest.makeSuite(RestTestCase)) suite.addTest(unittest.makeSuite(GremlinTestCase)) return suite
# -*- coding: utf-8 -*- # # Copyright 2011 James Thornton (http://jamesthornton.com) # BSD License (see LICENSE for details) # import unittest from bulbs.tests.testcase import BulbsTestCase from bulbs.element import Vertex, VertexProxy, Edge, EdgeProxy from bulbs.config import Config from bulbs.rexster import RexsterClient, REXSTER_URI from bulbs.rexster.index import VertexIndexProxy, EdgeIndexProxy, ManualIndex config = Config(REXSTER_URI) BulbsTestCase.client = RexsterClient(config) BulbsTestCase.index_class = ManualIndex # is this being used anywhere? -- JT 10/22/2012 class IndexTestCase(BulbsTestCase): 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")
def __init__(self): self.config = Config("http://localhost:8182/graphs/orientdbsample", username="******", password="******") self.client = RexsterClient(self.config)
class Mapper(): def __init__(self): self.config = Config("http://localhost:8182/graphs/orientdbsample", username="******", password="******") self.client = RexsterClient(self.config) def search(self): g = Graph(self.config) def show_vertices(self): vertices = client.get_all_vertices() res = vertices.get_results()[0] for r in res: print sj.dumps(r.data, sort_keys=True, indent=4) def root_save(self, root_input): # print "mapping.." odml_root = load(root_input) output = {} output['author'] = odml_root.author output['date'] = odml_root.date output['repository'] = odml_root.repository output['version'] = odml_root.version r_id = ((self.client.create_vertex(output)).get_results()[0]).get_id() # print "Root ID = " + r_id for section in odml_root.sections: s_id = self.section_save(section) self.client.create_edge(r_id, "root-section", s_id) self.client.create_edge(s_id, "section-root", r_id) def section_save(self, source_section): output = {} output['name'] = source_section.name output['type_name'] = source_section.type output['reference'] = source_section.reference output['definition'] = source_section.definition output['repository'] = source_section.repository output['mapping'] = source_section.mapping output['link'] = source_section.link output['include'] = source_section.include properties = [] for pro in source_section.properties: # print "property.." p = {} p["name"] = pro.name p["definition"] = pro.definition p["mapping"] = pro.mapping p["dependency"] = pro.dependency p["dependencyValue"] = pro.dependency_value values = [] for value in pro.values: v = {} v["value"] = value.value v["uncertainty"] = value.uncertainty v["unit"] = value.unit v["type_name"] = value.dtype v["definition"] = value.definition v["reference"] = value.reference v["filename"] = value.filename v["encoder"] = value.encoder v["checksum "] = value.checksum values.append(v) p['values'] = values properties.append(p) output['properties_coll'] = properties section_id = ((self.client.create_vertex(output)).get_results()[0]).get_id() for subsection in source_section.sections: s_id = self.section_save(subsection) self.client.create_edge(section_id, "section-section", s_id) self.client.create_edge(s_id, "section-section", section_id) return section_id