def test_get_node(self): skos_concept_iri = rdflib.URIRef( "http://www.w3.org/2004/02/skos/core#Concept") skos_concept_label = "skos:Concept" skos_concept_id = self.g.V().hasLabel( skos_concept_label).toList()[0].id skos_concept_node = self.g.V().hasLabel(skos_concept_label).toList()[0] # known_iri_str = "http://publications.europa.eu/resources/authority/celex/md_OJ_ID" n = rdf2g.get_node(self.g, skos_concept_iri) assert isinstance(n, Vertex), "The node is not found; 1" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label" n = rdf2g.get_node(self.g, skos_concept_label) assert isinstance(n, Vertex), "The node is not found; 2" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label" n = rdf2g.get_node(self.g, skos_concept_id) assert isinstance(n, Vertex), "The node is not found; 3" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label" n = rdf2g.get_node(self.g, skos_concept_node) assert isinstance(n, Vertex), "The node is not found; 4" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label"
def test_get_node_1(self): skos_concept_iri = rdflib.URIRef( "http://publications.europa.eu/resources/authority/lam/res_h9ci2wPXrcUXBh9JkkHzUY" ) skos_concept_label = "lamd:res_h9ci2wPXrcUXBh9JkkHzUY" pprint(self.g.V().hasLabel(skos_concept_label).toList()) skos_concept_id = self.g.V().hasLabel( skos_concept_label).toList()[0].id skos_concept_node = self.g.V().hasLabel(skos_concept_label).toList()[0] n = rdf2g.get_node(self.g, skos_concept_iri) assert isinstance(n, Vertex), "The node is not found; 1" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label" n = rdf2g.get_node(self.g, skos_concept_label) assert isinstance(n, Vertex), "The node is not found; 2" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label" n = rdf2g.get_node(self.g, skos_concept_id) assert isinstance(n, Vertex), "The node is not found; 3" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label" n = rdf2g.get_node(self.g, skos_concept_node) assert isinstance(n, Vertex), "The node is not found; 4" assert rdf2g.get_node_properties( self.g, n)["@label"] == skos_concept_label, "Wrong label"
def test_add_property(self): known_iri_str = "http://publications.europa.eu/resources/authority/celex/md_OJ_ID" n = rdf2g.get_node(self.g, known_iri_str) rdf2g.add_property(self.g, n, "property", "value", self.rdf_graph) props = rdf2g.get_node_properties(self.g, n) assert 'property' in props, "Expecting 'property' key among the node properties " rdf2g.add_property(self.g, n, rdflib.URIRef(known_iri_str), "super value", self.rdf_graph) props = rdf2g.get_node_properties(self.g, n) assert 'celexd:md_OJ_ID' in props, "Expecting 'celexd:md_OJ_ID' key among the node properties "
def test_get_node_properties(self): known_iri_str = "http://publications.europa.eu/resources/authority/celex/md_OJ_ID" n = rdf2g.get_node(self.g, known_iri_str) props = rdf2g.get_node_properties(self.g, n) assert 'iri' in props, "Expecting 'iri' key among the node properties "