def __init__(self, rdf_file, connection_string=rdf2g.DEFAULT_LOCAL_CONNECTION_STRING, generate_collections=False): self.content = None self.g = rdf2g.setup_graph(connection_string) self.generate_collections = generate_collections rdf2g.clear_graph(self.g) self.rdf_graph = rdflib.Graph() self.rdf_graph.parse(str(rdf_file), format=rdflib.util.guess_format(str(rdf_file))) rdf2g.clear_graph(self.g) rdf2g.load_rdf2g(self.g, self.rdf_graph)
def setUp(self): logging.basicConfig() logging.getLogger().setLevel(logging.DEBUG) self.longMessage = True # Print complete error message self.rdf_graph = rdflib.Graph() self.rdf_graph.parse(str(OUTPUT_FILE_LAM_PROPERTIES), format="ttl") logging.info('%s triples loaded into RDF graph' % str(len(self.rdf_graph))) self.g = rdf2g.setup_graph() rdf2g.clear_graph(self.g) rdf2g.load_rdf2g(self.g, self.rdf_graph)
def test_load_properties(self): self.rdf_graph_props = rdflib.Graph() self.rdf_graph_props.parse(str(LAM_PROPERTY_EXAMPLE), format="ttl") logging.info('%s triples loaded into RDF graph' % str(len(self.rdf_graph_props))) rdf2g.clear_graph(self.g) known_label = "lamd:md_DTN" assert rdf2g.load_rdf2g(self.g, self.rdf_graph_props), "Could not load the graph" assert rdf2g.get_node(self.g, known_label), "Could not find the node " + known_label
def test_loading(self): rdf2g.clear_graph(self.g) rdf2g.load_rdf2g(self.g, self.rdf_graph) assert len(self.g.V().toList()) > 0, "Nodes have not been created " assert len(self.g.E().toList()) > 0, "Edges have not been created "