From 00cd64377aec7c4c52ec4f0a265b99a195a95d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=95=D0=BC=D0=B5?= =?UTF-8?q?=D0=BB=D1=8C=D1=8F=D0=BD=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Thu, 3 Sep 2026 11:57:49 +0300 Subject: [PATCH] Fix date-dependent storage tests (use now-relative timestamps) --- tests/test_storage.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_storage.py b/tests/test_storage.py index 1b7ad21..d2d1db9 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -108,14 +108,15 @@ def test_save_and_get_latest_model_metrics(tmp_path) -> None: def test_history_upsert_same_day(tmp_path) -> None: storage = Storage(tmp_path / "cache.db") + timestamp = dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1) point = HistoryPoint( - timestamp=dt.datetime(2026, 8, 1, 12, 0), + timestamp=timestamp, amount_rub=Decimal("10.00"), tokens=TokenUsage(input_tokens=5), ) storage.save_history(point) point2 = HistoryPoint( - timestamp=dt.datetime(2026, 8, 1, 12, 0), + timestamp=timestamp, amount_rub=Decimal("15.00"), tokens=TokenUsage(input_tokens=8), ) @@ -151,7 +152,7 @@ def test_save_snapshot_combined(tmp_path) -> None: metrics=_metrics(), models=_models(), history_point=HistoryPoint( - timestamp=dt.datetime(2026, 8, 1, 12, 0), + timestamp=dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1), amount_rub=Decimal("854.83"), tokens=TokenUsage(input_tokens=100), ), @@ -225,7 +226,7 @@ def test_clear_removes_all_rows(tmp_path) -> None: storage = Storage(tmp_path / "cache.db") storage.save_history( HistoryPoint( - timestamp=dt.datetime(2026, 8, 18), + timestamp=dt.datetime.now(dt.timezone.utc) - dt.timedelta(days=1), amount_rub=Decimal("1"), tokens=TokenUsage(input_tokens=1), ) @@ -235,4 +236,4 @@ def test_clear_removes_all_rows(tmp_path) -> None: deleted = storage.clear() assert deleted >= 1 assert storage.get_history() == [] - assert storage.get_latest_consumption() is None + assert storage.get_latest_consumption() is None \ No newline at end of file