Skip to content

Commit 8e9e2e8

Browse files
committed
check if the range of has_input is NamedThing within the python file
1 parent d54a868 commit 8e9e2e8

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed
Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
import logging
13
from unittest import TestCase, main
24
from linkml_runtime.utils.schemaview import SchemaView
35
from tests.test_issues.environment import env
@@ -6,17 +8,27 @@ class TestLinkmlIssue497(TestCase):
68
env = env
79

810
def test_linkml_issue_497(self):
9-
view = SchemaView(env.input_path('linkml_issue_497.yaml'))
10-
biosample_processing = view.get_class('biosample processing')
11-
omics_processing = view.get_class('omics processing')
11+
12+
view = SchemaView(env.input_path('linkml_issue_497.yaml'))
13+
biosample_processing = view.get_class('biosample processing')
14+
omics_processing = view.get_class('omics processing')
1215

13-
has_input = view.get_slot('has input')
14-
has_input_bp = view.induced_slot('has input', 'biosample processing')
15-
has_input_op = view.induced_slot('has input', 'omics processing')
16+
has_input = view.get_slot('has input')
17+
has_input_bp = view.induced_slot('has input', 'biosample processing')
18+
has_input_op = view.induced_slot('has input', 'omics processing')
19+
20+
# testing schemaview ranges
21+
assert has_input.range == 'named thing'
22+
assert has_input_bp.range == 'biosample'
23+
assert has_input_op.range == 'biosample'
24+
25+
# test python file's has_input attribute
26+
with open(env.input_path('linkml_issue_497.py')) as f:
27+
for line in f:
28+
if re.match(r'\s*has_input.*NamedThing.*', line):
29+
logging.error('has_input range is NamedThing.', line.strip())
30+
assert False
1631

17-
assert has_input.range == 'named thing'
18-
assert has_input_bp.range == 'biosample'
19-
assert has_input_op.range == 'biosample'
2032

2133
if __name__ == "__main__":
22-
main()
34+
main()

0 commit comments

Comments
 (0)