Skip to content

Commit ba91031

Browse files
✅ Add tests
Adds a basic data test so jobs wont appear to fail.
1 parent 7ffc96a commit ba91031

File tree

6 files changed

+50
-8
lines changed

6 files changed

+50
-8
lines changed

docs/schema/include_access_model.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,6 @@ slots:
853853
- Study
854854
range: Publication
855855
multivalued: true
856-
inlined: true
857-
inlined_as_list: true
858856
expected_number_of_participants:
859857
name: expected_number_of_participants
860858
definition_uri: https://includedcc.org/include-access-model/expected_number_of_participants
@@ -1030,13 +1028,17 @@ classes:
10301028
description: Information about a specific publication.
10311029
title: Publication
10321030
from_schema: https://includedcc.org/include-access-model
1031+
is_a: Record
10331032
slots:
1033+
- uuid
1034+
- id
1035+
- external_id
10341036
- bibliographic_reference
10351037
- website
10361038
class_uri: includedcc:Publication
10371039
metamodel_version: 1.7.0
10381040
source_file: include_access_model.yaml
1039-
source_file_date: '2025-11-10T19:02:19'
1040-
source_file_size: 13601
1041-
generation_date: '2025-11-10T19:04:56'
1041+
source_file_date: '2025-11-10T19:12:50'
1042+
source_file_size: 13619
1043+
generation_date: '2025-11-10T19:23:24'
10421044

src/include_access_model/datamodel/include_access_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Auto generated from include_access_model.yaml by pythongen.py version: 0.0.1
2-
# Generation date: 2025-11-10T19:22:06
2+
# Generation date: 2025-11-10T20:17:42
33
# Schema: include-access-model
44
#
55
# id: https://includedcc.org/include-access-model

tests/data/invalid/DOI-001.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
id: 001

tests/data/valid/DOI-000.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
uuid: "e9d804b4-9d51-4c82-be25-876839de744e"
2+
id: "000"

tests/data/valid/Record-000.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/test_data.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""Data test."""
2+
import os
3+
import glob
4+
import pytest
5+
from pathlib import Path
6+
7+
import include_access_model.datamodel.include_access_model
8+
from linkml_runtime.loaders import yaml_loader
9+
10+
DATA_DIR_VALID = Path(__file__).parent / "data" / "valid"
11+
DATA_DIR_INVALID = Path(__file__).parent / "data" / "invalid"
12+
13+
VALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_VALID, '*.yaml'))
14+
INVALID_EXAMPLE_FILES = glob.glob(os.path.join(DATA_DIR_INVALID, '*.yaml'))
15+
16+
17+
@pytest.mark.parametrize("filepath", VALID_EXAMPLE_FILES)
18+
def test_valid_data_files(filepath):
19+
"""Test loading of all valid data files."""
20+
target_class_name = Path(filepath).stem.split("-")[0]
21+
tgt_class = getattr(
22+
include_access_model.datamodel.include_access_model,
23+
target_class_name,
24+
)
25+
obj = yaml_loader.load(filepath, target_class=tgt_class)
26+
assert obj
27+
28+
"""This may not work for every expected error type- it uses ValueError"""
29+
@pytest.mark.parametrize("filepath", INVALID_EXAMPLE_FILES)
30+
def test_valid_data_files(filepath):
31+
"""Test loading of all valid data files."""
32+
target_class_name = Path(filepath).stem.split("-")[0]
33+
tgt_class = getattr(
34+
include_access_model.datamodel.include_access_model,
35+
target_class_name,
36+
)
37+
with pytest.raises(ValueError):
38+
obj = yaml_loader.load(filepath, target_class=tgt_class)
39+

0 commit comments

Comments
 (0)