From 9774245f402ee08e912f8e6ffd5b7824dc70cb29 Mon Sep 17 00:00:00 2001 From: Mohammed Affan Date: Wed, 8 Jul 2026 22:15:36 +0530 Subject: [PATCH] test: add unit tests for unlimited budget duration --- litellm/litellm_core_utils/duration_parser.py | 2 +- tests/test_duration_parser.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/test_duration_parser.py diff --git a/litellm/litellm_core_utils/duration_parser.py b/litellm/litellm_core_utils/duration_parser.py index 39cd14b2b4e..d93639b1f4f 100644 --- a/litellm/litellm_core_utils/duration_parser.py +++ b/litellm/litellm_core_utils/duration_parser.py @@ -363,4 +363,4 @@ def _handle_month_reset(current_time: datetime, base_midnight: datetime, value: second=0, microsecond=0, tzinfo=current_time.tzinfo, - ) \ No newline at end of file + ) diff --git a/tests/test_duration_parser.py b/tests/test_duration_parser.py new file mode 100644 index 00000000000..9f780c1c3f6 --- /dev/null +++ b/tests/test_duration_parser.py @@ -0,0 +1,12 @@ +import pytest +from litellm.litellm_core_utils.duration_parser import duration_in_seconds + +def test_unlimited_budget_duration(): + # 1. Test that the bug is fixed (Empty/None values safely return None) + assert duration_in_seconds("None") is None + assert duration_in_seconds("null") is None + assert duration_in_seconds("") is None + assert duration_in_seconds(None) is None + + # 2. Test that normal math still works (30 days = 2,592,000 seconds) + assert duration_in_seconds("30d") == 2592000 \ No newline at end of file