-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_validate.py
More file actions
49 lines (41 loc) · 1.42 KB
/
test_validate.py
File metadata and controls
49 lines (41 loc) · 1.42 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
39
40
41
42
43
44
45
46
47
48
49
# Copyright © 2024, 2025 Brockmann Consult and contributors
# Permissions are hereby granted under the terms of the MIT License:
# https://opensource.org/licenses/MIT.
import unittest
import pytest
from zappend.config import validate_config
class ConfigValidateTest(unittest.TestCase):
def test_validate_empty_ok(self):
config = {}
self.assertIs(config, validate_config(config))
def test_validate_versions_ok(self):
config = {"version": 1, "zarr_version": 2}
self.assertIs(config, validate_config(config))
# noinspection PyMethodMayBeStatic
def test_validate_versions_fail(self):
config = {"zarr_version": 1}
with pytest.raises(
ValueError,
match="Invalid configuration: 2 was expected for zarr_version",
):
validate_config(config)
# noinspection PyMethodMayBeStatic
def test_validate_variable_fail(self):
config = {
"zarr_version": 2,
"variables": {
"chl": {
"dims": [10, 20, 30],
"encoding": {
"dtype": "int32",
},
}
},
}
with pytest.raises(
ValueError,
match="Invalid configuration:"
" [1-3]0 is not of type 'string'"
" for variables.chl.dims.[0-2]",
):
validate_config(config)