From 0bd3431b88ec7d8e4771b8b4b1d86fe2547c35e4 Mon Sep 17 00:00:00 2001 From: ANISAYAK MITRA <266799942+anisayakmitra-in@users.noreply.github.com> Date: Sun, 25 Oct 2026 18:33:50 +0530 Subject: [PATCH] test(proxy/stagger): add coverage for naive datetime shifting in _shift_datetime --- .../unit/proxy/common_utils/test_scheduled_job_stagger.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/proxy/common_utils/test_scheduled_job_stagger.py b/tests/unit/proxy/common_utils/test_scheduled_job_stagger.py index ce7d37cef24..a15538a780c 100644 --- a/tests/unit/proxy/common_utils/test_scheduled_job_stagger.py +++ b/tests/unit/proxy/common_utils/test_scheduled_job_stagger.py @@ -16,6 +16,7 @@ from litellm.constants import PTU_ROLLUP_JOB_ID, PTU_ROLLUP_LOCK_TTL_SECONDS from litellm.proxy._types import ScheduledJobStaggerSettings from litellm.proxy.common_utils.scheduled_job_stagger import ( _OffsetTrigger, + _shift_datetime, apply_scheduled_job_stagger, attach_job_timing_logger, offset_seconds, @@ -331,3 +332,9 @@ def test_offset_trigger_handles_dst_fall_back_without_looping(): count += 1 nrt = trigger.get_next_fire_time(nrt, now) assert count == 2, f"Failed for {label}: count={count}" + + +def test_shift_datetime_handles_naive_and_timezone_aware(): + naive = datetime(2026, 1, 1, 12, 0, 0) + assert _shift_datetime(naive, timedelta(seconds=10)) == datetime(2026, 1, 1, 12, 0, 10) + assert _shift_datetime(naive, -timedelta(seconds=10)) == datetime(2026, 1, 1, 11, 59, 50)