|
1 | | -import unittest |
2 | | - |
3 | 1 | from linkml_runtime.linkml_model import SchemaDefinition |
4 | 2 | from linkml_runtime.utils.introspection import object_class_definition, package_schemaview |
5 | 3 |
|
6 | 4 |
|
7 | | -class IntrospectionTestCase(unittest.TestCase): |
8 | | - def test_introspection_on_metamodel(self): |
9 | | - view = package_schemaview("linkml_runtime.linkml_model.meta") |
10 | | - for cn in ["class_definition", "type_definition", "slot_definition"]: |
11 | | - assert cn in view.all_classes() |
12 | | - for tn in ["uriorcurie", "string", "float"]: |
13 | | - assert tn in view.all_types() |
14 | | - obj = SchemaDefinition(id="x", name="x") |
15 | | - c = object_class_definition(obj) |
16 | | - assert "classes" in c.slots |
| 5 | +def test_introspection_on_metamodel(): |
| 6 | + """Test introspection capabilities on the linkml metamodel""" |
| 7 | + view = package_schemaview("linkml_runtime.linkml_model.meta") |
| 8 | + |
| 9 | + # Test that expected classes are present |
| 10 | + assert {"class_definition", "type_definition", "slot_definition"}.issubset(set(view.all_classes())) |
17 | 11 |
|
| 12 | + # Test that expected types are present |
| 13 | + assert {"uriorcurie", "string", "float"}.issubset(set(view.all_types())) |
18 | 14 |
|
19 | | -if __name__ == "__main__": |
20 | | - unittest.main() |
| 15 | + # Test object class definition introspection |
| 16 | + obj = SchemaDefinition(id="x", name="x") |
| 17 | + c = object_class_definition(obj) |
| 18 | + assert "classes" in c.slots |
0 commit comments