Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a test for induced slot alias fields. Additional CURIE tests #321

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/test_utils/input/kitchen_sink_noimports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ classes:
slots:
- street
- city
- postal code

Event:
slots:
Expand Down Expand Up @@ -348,6 +349,10 @@ slots:
multivalued: true
inlined_as_list: true

postal code:
alias: zip
range: string


enums:
FamilialRelationshipType:
Expand Down
1 change: 1 addition & 0 deletions tests/test_utils/test_metamodelcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_uriorcuries(self):
URIorCURIE(" ")
with self.assertRaises(ValueError):
URIorCURIE("[")
assert URIorCURIE.is_valid("NCIT:C176962")
lax()
URIorCURIE("1abc:def")
URIorCURIE("1:def")
Expand Down
19 changes: 19 additions & 0 deletions tests/test_utils/test_schemaview.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def test_children_method(self):
self.assertEqual(children, ['Adult'])

def test_all_aliases(self):
"""
This tests the aliases slot (not: alias)
:return:
"""
view = SchemaView(SCHEMA_NO_IMPORTS)
aliases = view.all_aliases()
self.assertIn("identifier", aliases["id"])
Expand All @@ -46,6 +50,21 @@ def test_all_aliases(self):
self.assertIn("dad", aliases["Adult"])
self.assertNotIn("test", aliases["Adult"])

def test_alias_slot(self):
"""
Tests the alias slot.

The induced slot alias should always be populated. For induced slots, it should default to the
name field if not present.
"""
view = SchemaView(SCHEMA_NO_IMPORTS)
for c in view.all_classes().values():
for s in view.class_induced_slots(c.name):
self.assertIsNotNone(s.alias)
postal_code_slot = view.induced_slot('postal code', 'Address')
self.assertEqual(postal_code_slot.name, 'postal code')
self.assertEqual(postal_code_slot.alias, 'zip')

def test_schemaview_enums(self):
view = SchemaView(SCHEMA_NO_IMPORTS)
with self.assertRaises(ValueError):
Expand Down
Loading