Skip to content

Commit 705d036

Browse files
committed
remove validation tests since pydantic already guarantees that.
1 parent 1e83839 commit 705d036

File tree

1 file changed

+0
-82
lines changed

1 file changed

+0
-82
lines changed

tests/unit/test_environment.py

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,13 @@
44
from unittest.mock import patch
55

66
import pytest
7-
from pydantic import ValidationError
87

98
from mdio.core.settings import MDIOSettings
109

1110

1211
class TestEnvironment:
1312
"""Test the Environment API module functions."""
1413

15-
@pytest.mark.parametrize(
16-
("value", "expected_type"),
17-
[
18-
(MDIOSettings().export_cpus, int),
19-
(MDIOSettings().import_cpus, int),
20-
(MDIOSettings().grid_sparsity_ratio_warn, float),
21-
(MDIOSettings().grid_sparsity_ratio_limit, float),
22-
(MDIOSettings().save_segy_file_header, bool),
23-
(MDIOSettings().raw_headers, bool),
24-
(MDIOSettings().ignore_checks, bool),
25-
(MDIOSettings().cloud_native, bool),
26-
],
27-
)
28-
def test_default_values(self, value: object, expected_type: type) -> None:
29-
"""Test all properties return correct types with defaults."""
30-
with patch.dict(os.environ, {}, clear=True):
31-
assert isinstance(value, expected_type)
32-
3314
@pytest.mark.parametrize(
3415
("env_var", "value", "property_name", "expected"),
3516
[
@@ -46,69 +27,6 @@ def test_env_var_overrides(self, env_var: str, value: str, property_name: str, e
4627
result = getattr(settings, property_name)
4728
assert result == expected
4829

49-
@pytest.mark.parametrize(
50-
("property_name", "env_var"),
51-
[
52-
("save_segy_file_header", "MDIO__IMPORT__SAVE_SEGY_FILE_HEADER"),
53-
("raw_headers", "MDIO__IMPORT__RAW_HEADERS"),
54-
("ignore_checks", "MDIO_IGNORE_CHECKS"),
55-
("cloud_native", "MDIO__IMPORT__CLOUD_NATIVE"),
56-
],
57-
)
58-
@pytest.mark.parametrize(
59-
("value", "expected"),
60-
[
61-
("1", True),
62-
("true", True),
63-
("yes", True),
64-
("on", True),
65-
("0", False),
66-
("false", False),
67-
("no", False),
68-
("off", False),
69-
("anything_else", False),
70-
("", False),
71-
],
72-
)
73-
def test_boolean_parsing(self, property_name: str, env_var: str, value: str, expected: bool) -> None:
74-
"""Test boolean parsing for all boolean properties."""
75-
with patch.dict(os.environ, {env_var: value}):
76-
settings = MDIOSettings()
77-
result = getattr(settings, property_name)
78-
assert result is expected
79-
80-
@pytest.mark.parametrize(
81-
("env_var"),
82-
[
83-
("MDIO__EXPORT__CPU_COUNT"),
84-
("MDIO__IMPORT__CPU_COUNT"),
85-
],
86-
)
87-
@pytest.mark.parametrize("invalid_value", ["invalid", "not_a_number", ""])
88-
def test_int_validation_errors(self, env_var: str, invalid_value: str) -> None:
89-
"""Test integer properties raise errors for invalid values."""
90-
with patch.dict(os.environ, {env_var: invalid_value}):
91-
with pytest.raises(ValidationError) as exc_info:
92-
MDIOSettings()
93-
assert env_var in str(exc_info.value)
94-
assert "int" in str(exc_info.value)
95-
96-
@pytest.mark.parametrize(
97-
("env_var"),
98-
[
99-
("MDIO__GRID__SPARSITY_RATIO_WARN"),
100-
("MDIO__GRID__SPARSITY_RATIO_LIMIT"),
101-
],
102-
)
103-
@pytest.mark.parametrize("invalid_value", ["invalid", "not_a_number", ""])
104-
def test_float_validation_errors(self, env_var: str, invalid_value: str) -> None:
105-
"""Test float properties raise errors for invalid values."""
106-
with patch.dict(os.environ, {env_var: invalid_value}):
107-
with pytest.raises(ValidationError) as exc_info:
108-
MDIOSettings()
109-
assert env_var in str(exc_info.value)
110-
assert "float" in str(exc_info.value)
111-
11230
def test_environment_isolation(self) -> None:
11331
"""Test that environment changes don't affect other tests."""
11432
original_values = {

0 commit comments

Comments
 (0)