From 66d4cce5f54e04fc477b50904a4111b4be5675c7 Mon Sep 17 00:00:00 2001 From: Chris Mungall Date: Wed, 2 Oct 2024 12:41:43 -0700 Subject: [PATCH] Add test for _base => @base See https://github.com/linkml/linkml/issues/2349 --- tests/test_loaders_dumpers/test_rdflib_dumper.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_loaders_dumpers/test_rdflib_dumper.py b/tests/test_loaders_dumpers/test_rdflib_dumper.py index 487ccb3a..8bd3318b 100644 --- a/tests/test_loaders_dumpers/test_rdflib_dumper.py +++ b/tests/test_loaders_dumpers/test_rdflib_dumper.py @@ -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 @@ -163,7 +164,7 @@ 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: @@ -171,6 +172,13 @@ def test_undeclared_prefix(self): 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