1+ import re
2+ import logging
13from unittest import TestCase , main
24from linkml_runtime .utils .schemaview import SchemaView
35from 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
2133if __name__ == "__main__" :
22- main ()
34+ main ()
0 commit comments