diff --git a/compiler_admin/services/files.py b/compiler_admin/services/files.py index 069c07d..7484b09 100644 --- a/compiler_admin/services/files.py +++ b/compiler_admin/services/files.py @@ -40,6 +40,9 @@ def __init__(self, env_file_path=None): if self._path and self._path.exists(): self._cache.update(read_json(self._path)) + def __contains__(self, key): + return key in self._cache + def __getitem__(self, key): return self._cache.get(key) diff --git a/tests/services/test_files.py b/tests/services/test_files.py index ac78412..c2db07d 100644 --- a/tests/services/test_files.py +++ b/tests/services/test_files.py @@ -92,6 +92,7 @@ def test_JsonFileCache(monkeypatch): cache = JsonFileCache("INFO_FILE") assert cache._path.exists() + assert "key" in cache assert cache.get("key") == "value" assert cache["key"] == "value" assert cache.get("other") is None @@ -108,3 +109,4 @@ def test_JsonFileCache_no_file(): assert cache._cache == {} assert cache._path is None assert cache.get("key") is None + assert "key" not in cache