|
1 | | -import unittest |
2 | 1 | from pathlib import Path |
3 | 2 |
|
| 3 | +import pytest |
4 | 4 | import yaml |
5 | 5 |
|
6 | 6 | from linkml_runtime.processing.referencevalidator import ( |
|
10 | 10 | from tests.test_processing import INPUT_DIR |
11 | 11 |
|
12 | 12 |
|
13 | | -class ArrayTestCase(unittest.TestCase): |
| 13 | +@pytest.fixture |
| 14 | +def normalizer(): |
| 15 | + """ReferenceValidator instance for array example schema.""" |
| 16 | + sv = SchemaView(str(Path(INPUT_DIR) / "array_example.yaml")) |
| 17 | + return ReferenceValidator(sv) |
| 18 | + |
| 19 | + |
| 20 | +@pytest.fixture |
| 21 | +def matrix_data(): |
| 22 | + """Load matrix data from array example data file.""" |
| 23 | + return yaml.safe_load(open(str(Path(INPUT_DIR) / "array_example_data.yaml"))) |
| 24 | + |
| 25 | + |
| 26 | +def test_array_normalization(normalizer, matrix_data): |
14 | 27 | """ |
15 | | - Tests array normalization |
| 28 | + Test that we can infer the collection form of a slot. |
16 | 29 |
|
| 30 | + Tests array normalization functionality. |
17 | 31 | See: https://linkml.io/linkml/howtos/multidimensional-arrays |
18 | 32 | """ |
19 | | - |
20 | | - def setUp(self) -> None: |
21 | | - sv = SchemaView(str(Path(INPUT_DIR) / "array_example.yaml")) |
22 | | - self.normalizer = ReferenceValidator(sv) |
23 | | - self.matrix = yaml.safe_load(open(str(Path(INPUT_DIR) / "array_example_data.yaml"))) |
24 | | - |
25 | | - def test_array_normalization(self): |
26 | | - """Test that we can infer the collection form of a slot.""" |
27 | | - norm = self.normalizer |
28 | | - matrix = norm.normalize(self.matrix) |
29 | | - vals = [int(x) for x in matrix["temperatures"]] |
30 | | - self.assertEqual([11, 12, 13, 21, 22, 23, 31, 32, 33], vals) |
| 33 | + matrix = normalizer.normalize(matrix_data) |
| 34 | + vals = [int(x) for x in matrix["temperatures"]] |
| 35 | + assert vals == [11, 12, 13, 21, 22, 23, 31, 32, 33] |
0 commit comments