|
11 | 11 |
|
12 | 12 | from linkml_runtime import MappingError, DataNotFoundError
|
13 | 13 | from linkml_runtime.dumpers import rdflib_dumper, yaml_dumper
|
| 14 | +from linkml_runtime.linkml_model import Prefix |
14 | 15 | from linkml_runtime.loaders import yaml_loader
|
15 | 16 | from linkml_runtime.loaders import rdflib_loader
|
16 | 17 | from linkml_runtime.utils.schemaview import SchemaView
|
@@ -166,14 +167,21 @@ def test_enums(self):
|
166 | 167 | print(catsx)
|
167 | 168 | self.assertCountEqual([org1type1, org1type2], catsx)
|
168 | 169 |
|
169 |
| - def test_undeclared_prefix(self): |
| 170 | + def test_undeclared_prefix_raises_error(self): |
170 | 171 | view = SchemaView(SCHEMA)
|
171 | 172 | org1 = Organization('foo') # not a CURIE or URI
|
172 | 173 | with self.assertRaises(Exception) as context:
|
173 | 174 | rdflib_dumper.as_rdf_graph(org1, schemaview=view)
|
174 | 175 | org1 = Organization('http://example.org/foo/o1')
|
175 | 176 | rdflib_dumper.as_rdf_graph(org1, schemaview=view)
|
176 | 177 |
|
| 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 | + |
177 | 185 | def test_rdflib_loader(self):
|
178 | 186 | """
|
179 | 187 | tests loading from an RDF graph
|
|
0 commit comments