|
16 | 16 | # under the License. |
17 | 17 | # pylint: disable=redefined-outer-name,arguments-renamed,fixme |
18 | 18 | from tempfile import TemporaryDirectory |
19 | | -from unittest import mock |
20 | 19 |
|
21 | 20 | import fastavro |
22 | 21 | import pytest |
|
52 | 51 |
|
53 | 52 | @pytest.fixture(autouse=True) |
54 | 53 | def reset_global_manifests_cache() -> None: |
55 | | - with manifest_module._manifest_cache_lock: |
56 | | - manifest_module._manifest_cache = manifest_module._init_manifest_cache() |
57 | 54 | clear_manifest_cache() |
58 | 55 |
|
59 | 56 |
|
@@ -1042,45 +1039,3 @@ def test_clear_manifest_cache() -> None: |
1042 | 1039 | cache_after = manifest_module._manifest_cache |
1043 | 1040 | assert cache_after is not None, "Cache should still be enabled after clear" |
1044 | 1041 | assert len(cache_after) == 0, "Cache should be empty after clear" |
1045 | | - |
1046 | | - |
1047 | | -@pytest.mark.parametrize( |
1048 | | - "env_vars,expected_enabled,expected_size", |
1049 | | - [ |
1050 | | - ({}, True, 128), # defaults |
1051 | | - ({"PYICEBERG_MANIFEST_CACHE_SIZE": "64"}, True, 64), |
1052 | | - ({"PYICEBERG_MANIFEST_CACHE_SIZE": "256"}, True, 256), |
1053 | | - ({"PYICEBERG_MANIFEST_CACHE_SIZE": "0"}, False, 0), # size=0 disables cache |
1054 | | - ], |
1055 | | -) |
1056 | | -def test_manifest_cache_config_valid_values(env_vars: dict[str, str], expected_enabled: bool, expected_size: int) -> None: |
1057 | | - """Test that valid config values are applied correctly.""" |
1058 | | - import os |
1059 | | - |
1060 | | - with mock.patch.dict(os.environ, env_vars, clear=False): |
1061 | | - with manifest_module._manifest_cache_lock: |
1062 | | - manifest_module._manifest_cache = manifest_module._init_manifest_cache() |
1063 | | - cache = manifest_module._manifest_cache |
1064 | | - |
1065 | | - if expected_enabled: |
1066 | | - assert cache is not None, "Cache should be enabled" |
1067 | | - assert cache.maxsize == expected_size, f"Cache size should be {expected_size}" |
1068 | | - else: |
1069 | | - assert cache is None, "Cache should be disabled" |
1070 | | - |
1071 | | - |
1072 | | -@pytest.mark.parametrize( |
1073 | | - "env_vars,expected_error_substring", |
1074 | | - [ |
1075 | | - ({"PYICEBERG_MANIFEST_CACHE_SIZE": "abc"}, "manifest-cache-size should be an integer"), |
1076 | | - ({"PYICEBERG_MANIFEST_CACHE_SIZE": "-5"}, "manifest-cache-size must be >= 0"), |
1077 | | - ], |
1078 | | -) |
1079 | | -def test_manifest_cache_config_invalid_values(env_vars: dict[str, str], expected_error_substring: str) -> None: |
1080 | | - """Test that invalid config values raise ValueError with appropriate message.""" |
1081 | | - import os |
1082 | | - |
1083 | | - with mock.patch.dict(os.environ, env_vars, clear=False): |
1084 | | - with pytest.raises(ValueError, match=expected_error_substring): |
1085 | | - with manifest_module._manifest_cache_lock: |
1086 | | - manifest_module._manifest_cache = manifest_module._init_manifest_cache() |
0 commit comments