Skip to content

Commit b5cbc5a

Browse files
committed
Adding extra tests for resolving relative file paths
1 parent a1db174 commit b5cbc5a

File tree

7 files changed

+82
-5
lines changed

7 files changed

+82
-5
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
id: four
2+
name: import_four
3+
title: Import Four
4+
description: |
5+
Import loaded by the StepChild class.
6+
imports:
7+
- linkml:types
8+
classes:
9+
Four:
10+
attributes:
11+
value:
12+
range: string
13+
ifabsent: "Four"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
id: one
2+
name: import_one
3+
title: Import One
4+
description: |
5+
Import loaded by the StepChild class.
6+
imports:
7+
- linkml:types
8+
- two
9+
classes:
10+
One:
11+
attributes:
12+
value:
13+
range: string
14+
ifabsent: "One"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
id: stepchild
2+
name: stepchild
3+
title: stepchild
4+
description: |
5+
Child class that imports files in the same directory as itself without consistently using `./` in the link notation.
6+
imports:
7+
- linkml:types
8+
- one
9+
- two
10+
- ./three
11+
classes:
12+
StepChild:
13+
attributes:
14+
value:
15+
range: string
16+
ifabsent: "StepChild"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
id: three
2+
name: import_three
3+
title: Import Three
4+
description: |
5+
Import loaded by the StepChild class.
6+
imports:
7+
- linkml:types
8+
- ./four
9+
classes:
10+
Three:
11+
attributes:
12+
value:
13+
range: string
14+
ifabsent: "Three"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
id: two
2+
name: import_two
3+
title: Import Two
4+
description: |
5+
Import loaded by the StepChild class.
6+
imports:
7+
- linkml:types
8+
classes:
9+
Two:
10+
attributes:
11+
value:
12+
range: string
13+
ifabsent: "Two"

tests/test_utils/input/imports_relative/L0_0/L1_0_0/main.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ imports:
88
- ../../L0_1/cousin
99
- ./L2_0_0_0/child
1010
- ./L2_0_0_1/child
11+
- L2_0_0_2/stepchild
1112
classes:
1213
Main:
1314
description: "Our intrepid main class!"
1415
attributes:
1516
value:
1617
range: string
17-
ifabsent: "Main"
18+
ifabsent: "Main"

tests/test_utils/test_schemaview.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
SCHEMA_NO_IMPORTS = Path(INPUT_DIR) / 'kitchen_sink_noimports.yaml'
2121
SCHEMA_WITH_IMPORTS = Path(INPUT_DIR) / 'kitchen_sink.yaml'
22-
SCHEMA_WITH_STRUCTURED_PATTERNS = Path(INPUT_DIR) / "pattern-example.yaml"
22+
SCHEMA_WITH_STRUCTURED_PATTERNS = Path(INPUT_DIR) / 'pattern-example.yaml'
2323
SCHEMA_IMPORT_TREE = Path(INPUT_DIR) / 'imports' / 'main.yaml'
2424
SCHEMA_RELATIVE_IMPORT_TREE = Path(INPUT_DIR) / 'imports_relative' / 'L0_0' / 'L1_0_0' / 'main.yaml'
2525
SCHEMA_RELATIVE_IMPORT_TREE2 = Path(INPUT_DIR) / 'imports_relative' / 'L0_2' / 'main.yaml'
@@ -357,7 +357,7 @@ def test_caching():
357357
view.add_class(ClassDefinition('X'))
358358
assert len(['X']) == len(view.all_classes())
359359
view.add_class(ClassDefinition('Y'))
360-
assert len(['X', 'Y']) == len(view.all_classes())
360+
assert len(['X', 'Y']) == len(view.all_classes())
361361
# bypass view method and add directly to schema;
362362
# in general this is not recommended as the cache will
363363
# not be updated
@@ -544,8 +544,13 @@ def test_imports_relative():
544544
'../../L0_1/L1_1_0/index',
545545
'../../L0_1/cousin',
546546
'../L1_0_1/dupe',
547-
'./L2_0_0_0/child',
548-
'./L2_0_0_1/child',
547+
'L2_0_0_0/child',
548+
'L2_0_0_1/child',
549+
'L2_0_0_2/two',
550+
'L2_0_0_2/one',
551+
'L2_0_0_2/four',
552+
'L2_0_0_2/three',
553+
'L2_0_0_2/stepchild',
549554
'main'
550555
]
551556

@@ -716,6 +721,7 @@ def test_slot_inheritance():
716721
with pytest.raises(ValueError):
717722
view.slot_ancestors('s5')
718723

724+
719725
def test_attribute_inheritance():
720726
"""
721727
Tests attribute inheritance edge cases.

0 commit comments

Comments
 (0)