Skip to content

Commit ccb0772

Browse files
authored
Merge pull request #342 from linkml/linkml-issue-2349
Add test for _base => @base
2 parents f53e0ee + 66d4cce commit ccb0772

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/test_loaders_dumpers/test_rdflib_dumper.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from linkml_runtime import MappingError, DataNotFoundError
1313
from linkml_runtime.dumpers import rdflib_dumper, yaml_dumper
14+
from linkml_runtime.linkml_model import Prefix
1415
from linkml_runtime.loaders import yaml_loader
1516
from linkml_runtime.loaders import rdflib_loader
1617
from linkml_runtime.utils.schemaview import SchemaView
@@ -166,14 +167,21 @@ def test_enums(self):
166167
print(catsx)
167168
self.assertCountEqual([org1type1, org1type2], catsx)
168169

169-
def test_undeclared_prefix(self):
170+
def test_undeclared_prefix_raises_error(self):
170171
view = SchemaView(SCHEMA)
171172
org1 = Organization('foo') # not a CURIE or URI
172173
with self.assertRaises(Exception) as context:
173174
rdflib_dumper.as_rdf_graph(org1, schemaview=view)
174175
org1 = Organization('http://example.org/foo/o1')
175176
rdflib_dumper.as_rdf_graph(org1, schemaview=view)
176177

178+
def test_base_prefix(self):
179+
view = SchemaView(SCHEMA)
180+
view.schema.prefixes["_base"] = Prefix("_base", "http://example.org/")
181+
org1 = Organization('foo') # not a CURIE or URI
182+
g = rdflib_dumper.as_rdf_graph(org1, schemaview=view)
183+
assert (URIRef('http://example.org/foo'), RDF.type, SDO.Organization) in g
184+
177185
def test_rdflib_loader(self):
178186
"""
179187
tests loading from an RDF graph

0 commit comments

Comments
 (0)