|
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
|
@@ -163,14 +164,21 @@ def test_enums(self):
|
163 | 164 | print(catsx)
|
164 | 165 | self.assertCountEqual([org1type1, org1type2], catsx)
|
165 | 166 |
|
166 |
| - def test_undeclared_prefix(self): |
| 167 | + def test_undeclared_prefix_raises_error(self): |
167 | 168 | view = SchemaView(SCHEMA)
|
168 | 169 | org1 = Organization('foo') # not a CURIE or URI
|
169 | 170 | with self.assertRaises(Exception) as context:
|
170 | 171 | rdflib_dumper.as_rdf_graph(org1, schemaview=view)
|
171 | 172 | org1 = Organization('http://example.org/foo/o1')
|
172 | 173 | rdflib_dumper.as_rdf_graph(org1, schemaview=view)
|
173 | 174 |
|
| 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 | + |
174 | 182 | def test_rdflib_loader(self):
|
175 | 183 | """
|
176 | 184 | tests loading from an RDF graph
|
|
0 commit comments