test(batch_rate_limiter): pin the TPD reset clock to UTC so the test passes in any timezone

The test fed the limiter naive datetimes and asserted a UTC reset string. The limiter turns its clock into an epoch with timestamp(), which reads a naive datetime as local time, so on a box outside UTC the asserted 08:00 UTC reset came back shifted by the local offset. The clock values now carry tzinfo=timezone.utc.
This commit is contained in:
mateo-berri 2026-10-23 07:41:43 -07:00
parent f2118fc767
commit debfe7475d

View file

@ -72,7 +72,7 @@ async def test_batch_over_rpm_and_tpm_but_under_tpd_is_accepted():
@pytest.mark.asyncio
async def test_cumulative_batch_tokens_over_tpd_returns_429_with_remaining_daily_window():
window_start = datetime(2026, 9, 13, 8, 0, 0)
window_start = datetime(2026, 9, 13, 8, 0, 0, tzinfo=timezone.utc)
clock = _Clock(window_start)
_internal_usage_cache, _rate_limiter, batch_limiter = _make_limiters(clock)
user_api_key_dict = UserAPIKeyAuth(api_key=hash_token("tpd-key-2"), rpm_limit=1, tpd_limit=1000)
@ -82,7 +82,7 @@ async def test_cumulative_batch_tokens_over_tpd_returns_429_with_remaining_daily
data={},
batch_usage=BatchFileUsage(total_tokens=600, request_count=6),
)
clock.now = datetime(2026, 9, 13, 11, 0, 0)
clock.now = datetime(2026, 9, 13, 11, 0, 0, tzinfo=timezone.utc)
with pytest.raises(HTTPException) as exc:
await batch_limiter._check_and_increment_batch_counters(
user_api_key_dict=user_api_key_dict,