Skip to content

Commit

Permalink
Merge pull request #342 from linkml/linkml-issue-2349
Browse files Browse the repository at this point in the history
Add test for _base => @base
  • Loading branch information
cmungall authored Oct 4, 2024
2 parents f53e0ee + 66d4cce commit ccb0772
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_loaders_dumpers/test_rdflib_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from linkml_runtime import MappingError, DataNotFoundError
from linkml_runtime.dumpers import rdflib_dumper, yaml_dumper
from linkml_runtime.linkml_model import Prefix
from linkml_runtime.loaders import yaml_loader
from linkml_runtime.loaders import rdflib_loader
from linkml_runtime.utils.schemaview import SchemaView
Expand Down Expand Up @@ -166,14 +167,21 @@ def test_enums(self):
print(catsx)
self.assertCountEqual([org1type1, org1type2], catsx)

def test_undeclared_prefix(self):
def test_undeclared_prefix_raises_error(self):
view = SchemaView(SCHEMA)
org1 = Organization('foo') # not a CURIE or URI
with self.assertRaises(Exception) as context:
rdflib_dumper.as_rdf_graph(org1, schemaview=view)
org1 = Organization('http://example.org/foo/o1')
rdflib_dumper.as_rdf_graph(org1, schemaview=view)

def test_base_prefix(self):
view = SchemaView(SCHEMA)
view.schema.prefixes["_base"] = Prefix("_base", "http://example.org/")
org1 = Organization('foo') # not a CURIE or URI
g = rdflib_dumper.as_rdf_graph(org1, schemaview=view)
assert (URIRef('http://example.org/foo'), RDF.type, SDO.Organization) in g

def test_rdflib_loader(self):
"""
tests loading from an RDF graph
Expand Down

0 comments on commit ccb0772

Please sign in to comment.