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)