From 8c54fab88bd66c5d2b24966c0265272b6d3b4443 Mon Sep 17 00:00:00 2001 From: Raffael Herrmann Date: Mon, 1 Jun 2026 13:20:12 +0200 Subject: [PATCH] Restore backend/tests/test_statistics.py and keep only the targeted timezone fallback assertion change --- backend/tests/test_statistics.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/tests/test_statistics.py b/backend/tests/test_statistics.py index ae063a1..936c925 100644 --- a/backend/tests/test_statistics.py +++ b/backend/tests/test_statistics.py @@ -206,7 +206,19 @@ def test_statistics_invalid_timezone_falls_back_to_utc(client: Any, session: Ses resp = client.get("/api/statistics") assert resp.status_code == 200 - assert resp.json()["books_finished_per_month"] == [{"month": "2026-05", "count": 1}] + data = resp.json() + now = datetime.now(timezone.utc) + expected_months = [] + year, month = 2026, 5 + while (year < now.year) or (year == now.year and month <= now.month): + expected_months.append(f"{year:04d}-{month:02d}") + month += 1 + if month > 12: + month = 1 + year += 1 + assert data["books_finished_per_month"] == [ + {"month": m, "count": 1 if m == "2026-05" else 0} for m in expected_months + ] def test_pages_per_day_fallback_books_without_progress(client: Any) -> None: