Skip to content

Fix: JsonFileCache contains #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler_admin/services/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions tests/services/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Loading