Skip to content

Commit 1d0fd14

Browse files
committed
adjust fixtures according to pr
1 parent 9d0579e commit 1d0fd14

File tree

2 files changed

+29
-35
lines changed

2 files changed

+29
-35
lines changed

Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ update_model:
1010
cp -pr $(MODEL_DIR)/* linkml_runtime/linkml_model
1111

1212
test:
13-
poetry run python -m unittest discover
1413
poetry run pytest
1514

1615

tests/test_utils/test_schemaview.py

+29-34
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,33 @@ def view():
4242
return SchemaView(SCHEMA_WITH_IMPORTS)
4343

4444

45-
def test_children_method():
46-
view = SchemaView(SCHEMA_NO_IMPORTS)
47-
children = view.get_children("Person")
48-
assert children == ['Adult']
49-
50-
def test_all_aliases():
51-
"""
52-
This tests the aliases slot (not: alias)
53-
:return:
54-
"""
55-
view = SchemaView(SCHEMA_NO_IMPORTS)
56-
aliases = view.all_aliases()
57-
assert "identifier" in aliases["id"]
58-
assert "A" in aliases["subset A"]
59-
assert "B" in aliases["subset B"]
60-
assert "dad" in aliases["Adult"]
61-
62-
def test_alias_slot():
45+
def test_children_method(schema_view_no_imports):
46+
view = schema_view_no_imports
47+
children = view.get_children("Person")
48+
assert children == ['Adult']
49+
50+
51+
def test_all_aliases(vischema_view_no_imports):
52+
"""
53+
This tests the aliases slot (not: alias)
54+
:return:
55+
"""
56+
view = schema_view_no_imports
57+
aliases = view.all_aliases()
58+
assert "identifier" in aliases["id"]
59+
assert "A" in aliases["subset A"]
60+
assert "B" in aliases["subset B"]
61+
assert "dad" in aliases["Adult"]
62+
63+
def test_alias_slot(schema_view_no_imports):
6364
"""
6465
Tests the alias slot.
6566
6667
The induced slot alias should always be populated. For induced slots, it should default to the
6768
name field if not present.
6869
6970
"""
70-
71-
view = SchemaView(SCHEMA_NO_IMPORTS)
72-
71+
view = schema_view_no_imports
7372
for c in view.all_classes().values():
7473
for s in view.class_induced_slots(c.name):
7574
assert s.alias is not None # Assert that alias is not None
@@ -79,8 +78,8 @@ def test_alias_slot():
7978
assert postal_code_slot.alias == 'zip' # Assert alias is 'zip'
8079

8180

82-
def test_schemaview_enums():
83-
view = SchemaView(SCHEMA_NO_IMPORTS)
81+
def test_schemaview_enums(schema_view_no_imports):
82+
view = schema_view_no_imports
8483

8584
# Test for ValueError when passing incorrect parameters
8685
with pytest.raises(ValueError):
@@ -322,9 +321,9 @@ def test_schemaview(schema_view_no_imports):
322321
s = view.induced_slot(sn, 'Dataset')
323322
logger.debug(s)
324323

325-
def test_rollup_rolldown():
324+
def test_rollup_rolldown(schema_view_no_imports):
326325
# no import schema
327-
view = SchemaView(SCHEMA_NO_IMPORTS)
326+
view = schema_view_no_imports
328327
element_name = 'Event'
329328
roll_up(view, element_name)
330329
for slot in view.class_induced_slots(element_name):
@@ -374,17 +373,15 @@ def test_caching():
374373
assert len(['Y', 'Z', 'W']) == len(view.all_classes())
375374

376375

377-
def test_import_map():
376+
def test_import_map(view):
378377
"""
379378
Path to import file should be configurable
380379
"""
381380
for im in [{"core": "/no/such/file"}, {"linkml:": "/no/such/file"}]:
382381
with pytest.raises(FileNotFoundError):
383-
view = SchemaView(SCHEMA_WITH_IMPORTS, importmap=im)
384382
view.all_classes()
385383

386384
for im in [None, {}, {"core": "core"}]:
387-
view = SchemaView(SCHEMA_WITH_IMPORTS, importmap=im)
388385
view.all_classes()
389386
assert view.imports_closure().sort() == ['kitchen_sink', 'core', 'linkml:types'].sort() # Assert imports closure
390387
assert ACTIVITY in view.all_classes() # Assert ACTIVITY is in all classes
@@ -483,9 +480,8 @@ def test_imports(view):
483480
assert height.unit.ucum_code == "m"
484481

485482

486-
def test_imports_from_schemaview():
483+
def test_imports_from_schemaview(view):
487484
"""view should by default dynamically include imports chain"""
488-
view = SchemaView(SCHEMA_WITH_IMPORTS)
489485
view2 = SchemaView(view.schema)
490486
assert len(view.all_classes()) == len(view2.all_classes())
491487
assert len(view.all_classes(imports=False)) == len(view2.all_classes(imports=False))
@@ -575,11 +571,10 @@ def test_direct_remote_imports_additional():
575571
class_count = len(view.all_classes())
576572
assert class_count > 0
577573

578-
def test_merge_imports():
574+
def test_merge_imports(view):
579575
"""
580576
ensure merging and merging imports closure works
581577
"""
582-
view = SchemaView(SCHEMA_WITH_IMPORTS)
583578
all_c = copy(view.all_classes())
584579
all_c_noi = copy(view.all_classes(imports=False))
585580
assert len(all_c_noi) < len(all_c)
@@ -793,8 +788,7 @@ def test_metamodel_in_schemaview():
793788
assert exp_slot_uri is not None
794789

795790

796-
def test_get_classes_by_slot():
797-
sv = SchemaView(SCHEMA_WITH_IMPORTS)
791+
def test_get_classes_by_slot(view):
798792
slot = sv.get_slot(AGE_IN_YEARS)
799793
actual_result = sv.get_classes_by_slot(slot)
800794
expected_result = ["Person"]
@@ -833,6 +827,7 @@ def test_materialize_patterns_attribute():
833827

834828

835829
def test_mergeimports():
830+
# note the change here to include an extra param not in the fixture
836831
sv = SchemaView(SCHEMA_WITH_IMPORTS, merge_imports=False)
837832
classes_list = list(sv.schema.classes.keys())
838833
assert "activity" not in classes_list

0 commit comments

Comments
 (0)