-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from linkml/998_enum_slot_links
Add function to get all slots using named enum as range
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
id: https://w3id.org/linkml/examples/personinfo | ||
name: personinfo | ||
prefixes: | ||
linkml: https://w3id.org/linkml/ | ||
schema: http://schema.org/ | ||
personinfo: https://w3id.org/linkml/examples/personinfo/ | ||
ORCID: https://orcid.org/ | ||
imports: | ||
- linkml:types | ||
default_range: string | ||
|
||
classes: | ||
Person: | ||
class_uri: schema:Person | ||
attributes: | ||
id: | ||
identifier: true | ||
employed: | ||
range: EmploymentStatusEnum | ||
past_relationship: | ||
range: RelationshipStatusEnum | ||
|
||
|
||
slots: | ||
status: | ||
range: PersonStatusEnum | ||
relationship: | ||
range: RelationshipStatusEnum | ||
|
||
enums: | ||
PersonStatusEnum: | ||
permissible_values: | ||
ALIVE: | ||
DEAD: | ||
UNKNOWN: | ||
EmployedStatusEnum: | ||
permissible_values: | ||
EMPLOYED: | ||
UNEMPLOYED: | ||
UNKNOWN: | ||
RelationshipStatusEnum: | ||
permissible_values: | ||
UNKNOWN: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import logging | ||
import unittest | ||
from unittest import TestCase | ||
from linkml_runtime.utils.schemaview import SchemaView | ||
|
||
from tests.test_issues.environment import env | ||
|
||
|
||
class Issue998TestCase(TestCase): | ||
""" | ||
https://github.com/linkml/linkml/issues/998 | ||
""" | ||
env = env | ||
|
||
def test_issue_998_schema_slot(self): | ||
view = SchemaView(env.input_path('linkml_issue_998.yaml')) | ||
enum_slots = view.get_slots_by_enum("PersonStatusEnum") | ||
# assert type(enum_slots) is List[SlotDefinition] | ||
assert len(enum_slots) == 1 | ||
assert enum_slots[0].name == "status" | ||
|
||
def test_issue_998_attribute_slot(self): | ||
view = SchemaView(env.input_path('linkml_issue_998.yaml')) | ||
enum_slots = view.get_slots_by_enum("EmploymentStatusEnum") | ||
assert len(enum_slots) == 1 | ||
assert enum_slots[0].name == "employed" | ||
|
||
def test_issue_998_schema_and_atribute_slots(self): | ||
view = SchemaView(env.input_path('linkml_issue_998.yaml')) | ||
enum_slots = view.get_slots_by_enum("RelationshipStatusEnum") | ||
assert len(enum_slots) == 2 | ||
assert enum_slots[0].name == "relationship" | ||
assert enum_slots[1].name == "past_relationship" | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |