|
| 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