Skip to content

Commit d72eea6

Browse files
committed
Add basic unit test for v1 dataset schema validation
1 parent 3847700 commit d72eea6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/unit/test_schema.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""Test the schema for the v1 dataset."""
2+
3+
from mdio.schemas.v1 import Dataset as V1Dataset
4+
5+
6+
TEST_SCHEMA = {
7+
"metadata": {
8+
"name": "test_dataset",
9+
"api_version": "1.0.0",
10+
"created_on": "2023-01-01T00:00:00Z",
11+
},
12+
"variables": [
13+
{
14+
"name": "actual_variable",
15+
"data_type": "float32",
16+
"dimensions": ["dim0", "dim1"],
17+
"compressor": {"name": "blosc", "level": 3},
18+
"coordinates": ["coord"],
19+
"metadata": {
20+
"chunk_grid": {
21+
"name": "regular",
22+
"configuration": {"chunk_shape": [10, 20]},
23+
},
24+
},
25+
},
26+
{
27+
"name": "coord",
28+
"data_type": "float32",
29+
"dimensions": ["dim0", "dim1"],
30+
"metadata": {
31+
"chunk_grid": {
32+
"name": "regular",
33+
"configuration": {"chunk_shape": [10, 20]},
34+
},
35+
"units_v1": {"length": "m"},
36+
},
37+
},
38+
{
39+
"name": "dim0",
40+
"data_type": "int32",
41+
"dimensions": [{"name": "dim0", "size": 100}],
42+
},
43+
{
44+
"name": "dim1",
45+
"data_type": "int32",
46+
"dimensions": [{"name": "dim1", "size": 200}],
47+
},
48+
],
49+
}
50+
51+
52+
def test_dataset_schema_validation():
53+
"""Test that the dataset schema validates correctly."""
54+
V1Dataset.model_validate(TEST_SCHEMA)

0 commit comments

Comments
 (0)