-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_data.py
More file actions
39 lines (32 loc) · 1.32 KB
/
test_data.py
File metadata and controls
39 lines (32 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Data test."""
import os
import glob
import pytest
from pathlib import Path
import include_access_model.datamodel.include_access_model
from linkml_runtime.loaders import yaml_loader
DATA_DIR_VALID = Path(__file__).parent / "data" / "valid"
DATA_DIR_INVALID = Path(__file__).parent / "data" / "invalid"
VALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_VALID, '*.yaml'))
INVALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_INVALID, '*.yaml'))
@pytest.mark.parametrize("filepath", VALID_EXAMPLE_FILES)
def test_valid_data_files(filepath):
"""Test loading of all valid data files."""
target_class_name = Path(filepath).stem.split("-")[0]
tgt_class = getattr(
include_access_model.datamodel.include_access_model,
target_class_name,
)
obj = yaml_loader.load(filepath, target_class=tgt_class)
assert obj
"""This may not work for every expected error type- it uses ValueError"""
@pytest.mark.parametrize("filepath", INVALID_EXAMPLE_FILES)
def test_valid_data_files(filepath):
"""Test loading of all valid data files."""
target_class_name = Path(filepath).stem.split("-")[0]
tgt_class = getattr(
include_access_model.datamodel.include_access_model,
target_class_name,
)
with pytest.raises(ValueError):
obj = yaml_loader.load(filepath, target_class=tgt_class)