This commit is contained in:
@@ -120,6 +120,43 @@ def test_clear_sales_cache_removes_shared_page_cache_files(tmp_path, monkeypatch
|
||||
assert not cache_file.exists()
|
||||
|
||||
|
||||
def test_growth_cache_shared_file_roundtrip(tmp_path, monkeypatch):
|
||||
from services import cache_service
|
||||
|
||||
shared_cache = tmp_path / "growth_analysis_cache.pkl"
|
||||
monkeypatch.setattr(cache_service, "_GROWTH_SHARED_CACHE_FILE", shared_cache)
|
||||
|
||||
cache_service.clear_growth_cache()
|
||||
cache_service.set_growth_cache(
|
||||
{"labels": ["2026-05"], "revenue": [1000]},
|
||||
{"ytd_revenue": 1000},
|
||||
source_fingerprint=("2026-05-17", 10),
|
||||
)
|
||||
|
||||
cache_service._GROWTH_ANALYSIS_CACHE = {
|
||||
"chart_data": None,
|
||||
"kpi": None,
|
||||
"timestamp": None,
|
||||
"source_fingerprint": None,
|
||||
}
|
||||
|
||||
assert cache_service.is_growth_cache_valid(("2026-05-17", 10))
|
||||
assert cache_service.get_growth_cache()["chart_data"]["revenue"] == [1000]
|
||||
assert shared_cache.exists()
|
||||
|
||||
|
||||
def test_clear_growth_cache_removes_shared_file(tmp_path, monkeypatch):
|
||||
from services import cache_service
|
||||
|
||||
shared_cache = tmp_path / "growth_analysis_cache.pkl"
|
||||
shared_cache.write_bytes(b"stale")
|
||||
monkeypatch.setattr(cache_service, "_GROWTH_SHARED_CACHE_FILE", shared_cache)
|
||||
|
||||
cache_service.clear_growth_cache()
|
||||
|
||||
assert not shared_cache.exists()
|
||||
|
||||
|
||||
def test_daily_sales_shared_view_cache_roundtrip(tmp_path, monkeypatch):
|
||||
from routes import daily_sales_routes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user