From debfe7475d1ed5a0be64b3e36470e4eec142faae Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 23 Oct 2026 07:41:43 -0700 Subject: [PATCH] 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. --- tests/unit/proxy/hooks/test_batch_rate_limiter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/proxy/hooks/test_batch_rate_limiter.py b/tests/unit/proxy/hooks/test_batch_rate_limiter.py index b10cd9e7107..98ab07ca30b 100644 --- a/tests/unit/proxy/hooks/test_batch_rate_limiter.py +++ b/tests/unit/proxy/hooks/test_batch_rate_limiter.py @@ -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,