diff --git a/tests/test_incumbent_routing.py b/tests/test_incumbent_routing.py index 8057368..bf03738 100644 --- a/tests/test_incumbent_routing.py +++ b/tests/test_incumbent_routing.py @@ -12,6 +12,7 @@ The database tests use the same offline temp-DB pattern as import sqlite3 import tempfile +from datetime import datetime, timezone from pathlib import Path import pytest @@ -469,16 +470,21 @@ def _seed_measured_cache_rate(conn, provider, model_id, objective.incumbent_rate_min_observations defaults to 25, so we seed enough rows to clear the floor. + + Rows are stamped "now", not a fixed date: _measured_cache_rates only reads + rows inside objective.cache_rate_window_hours (168), so a literal date + ages out of the window and the incumbent silently falls back to the + assumed rate. That is how this fixture started failing on 2026-09-20. """ + observed_at = datetime.now(timezone.utc).isoformat() for _ in range(observations): conn.execute( """INSERT INTO energy_observations ( model_id, provider, task_category, prompt_tokens, completion_tokens, cached_prompt_tokens, cached_tokens_source, observed_at - ) VALUES (?, ?, 'general', ?, 500, ?, 'reported', - '2026-09-13T00:00:00+00:00')""", - (model_id, provider, prompt_tokens, cached_tokens), + ) VALUES (?, ?, 'general', ?, 500, ?, 'reported', ?)""", + (model_id, provider, prompt_tokens, cached_tokens, observed_at), ) conn.commit()