From dbbc2c9ba8f2c643d6f6339359c925facf7ee679 Mon Sep 17 00:00:00 2001 From: FugoP <264910004+AgentGymLeader@users.noreply.github.com> Date: Thu, 11 Jun 2026 17:36:14 +0900 Subject: [PATCH] test: exercise relative week semantics with non-Monday base dates + add docstring Signed-off-by: FugoP <264910004+AgentGymLeader@users.noreply.github.com> --- .../litellm_core_utils/test_duration_parser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_litellm/litellm_core_utils/test_duration_parser.py b/tests/test_litellm/litellm_core_utils/test_duration_parser.py index f7a86fb032b..3e4446c6672 100644 --- a/tests/test_litellm/litellm_core_utils/test_duration_parser.py +++ b/tests/test_litellm/litellm_core_utils/test_duration_parser.py @@ -35,13 +35,19 @@ class TestStandardizedResetTime(unittest.TestCase): self.assertEqual(custom_day_result, custom_day_expected) def test_week_based_resets(self): + """Test week-based reset durations (1w, 2w). + 1w snaps to the next Monday at midnight (same as 7d). + 2w advances exactly 14 days from the current date at midnight. + """ + # 1w from a Wednesday -> next Monday (5 days away, not 7) wednesday = datetime(2023, 5, 17, 15, 45, 0, tzinfo=timezone.utc) weekly_expected = datetime(2023, 5, 22, 0, 0, 0, tzinfo=timezone.utc) weekly_result = get_next_standardized_reset_time("1w", wednesday, "UTC") self.assertEqual(weekly_result, weekly_expected) - base_time = datetime(2023, 5, 15, 10, 30, 0, tzinfo=timezone.utc) - two_week_expected = datetime(2023, 5, 29, 0, 0, 0, tzinfo=timezone.utc) + # 2w from a Wednesday -> exactly 14 days out (lands on a Wednesday, not Monday) + base_time = datetime(2023, 5, 17, 10, 30, 0, tzinfo=timezone.utc) + two_week_expected = datetime(2023, 5, 31, 0, 0, 0, tzinfo=timezone.utc) two_week_result = get_next_standardized_reset_time("2w", base_time, "UTC") self.assertEqual(two_week_result, two_week_expected)