Skip to content

Commit 66d4cce

Browse files
committed
Add test for _base => @base
See linkml/linkml#2349
1 parent 9fd5a3e commit 66d4cce

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
@@ -163,14 +164,21 @@ def test_enums(self):
163164
print(catsx)
164165
self.assertCountEqual([org1type1, org1type2], catsx)
165166

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

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

0 commit comments

Comments
 (0)