Skip to content

Commit 67fe2e1

Browse files
committed
Add test for remote import without linkml prefix
1 parent 8a8ee69 commit 67fe2e1

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/test_utils/test_schemaview.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from linkml_runtime.dumpers import yaml_dumper
1010
from linkml_runtime.linkml_model.meta import SchemaDefinition, ClassDefinition, SlotDefinitionName, SlotDefinition, \
11-
ClassDefinitionName
11+
ClassDefinitionName, Prefix
1212
from linkml_runtime.loaders.yaml_loader import YAMLLoader
1313
from linkml_runtime.utils.introspection import package_schemaview
1414
from linkml_runtime.utils.schemaview import SchemaView, SchemaUsage, OrderedBy
@@ -533,6 +533,41 @@ def test_metamodel_imports(self):
533533
self.assertGreater(len(sv.all_classes()), 20)
534534
self.assertCountEqual(all_classes, sv.all_classes())
535535

536+
def test_non_linkml_remote_import(self):
537+
"""
538+
Test that a remote import _not_ using the linkml prefix works
539+
540+
See: https://github.com/linkml/linkml/issues/1627
541+
"""
542+
schema = SchemaDefinition(
543+
id='test_non_linkml_remote_import',
544+
name='test_non_linkml_remote_import',
545+
prefixes=[
546+
Prefix(
547+
prefix_prefix="foo",
548+
prefix_reference="https://w3id.org/linkml"
549+
)
550+
],
551+
imports=[
552+
"foo:types"
553+
],
554+
slots=[
555+
SlotDefinition(
556+
name="an_int",
557+
range="integer"
558+
)
559+
],
560+
classes=[
561+
ClassDefinition(
562+
name="AClass",
563+
slots=["an_int"]
564+
)
565+
]
566+
)
567+
sv = SchemaView(schema)
568+
slots = sv.class_induced_slots("AClass", imports=True)
569+
self.assertEqual(len(slots), 1)
570+
536571

537572
def test_traversal(self):
538573
schema = SchemaDefinition(id='test', name='traversal-test')

0 commit comments

Comments
 (0)