Spaces:
Paused
Paused
Download tests/test_litellm/proxy/common_utils/test_timezone_utils.py from DesertWolf/test3: direct link, hf CLI and curl.
- Browser
- Download file 992 Bytes
-
https://huggingface.co/spaces/DesertWolf/test3/resolve/main/tests/test_litellm/proxy/common_utils/test_timezone_utils.py
- Command line
-
hf download hf://spaces/DesertWolf/test3/tests/test_litellm/proxy/common_utils/test_timezone_utils.py
-
curl -L -o test_timezone_utils.py https://huggingface.co/spaces/DesertWolf/test3/resolve/main/tests/test_litellm/proxy/common_utils/test_timezone_utils.py
992 Bytes
| import asyncio | |
| import json | |
| import os | |
| import sys | |
| import time | |
| from datetime import datetime, timedelta, timezone | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| sys.path.insert( | |
| 0, os.path.abspath("../../..") | |
| ) # Adds the parent directory to the system path | |
| from litellm.proxy.common_utils.timezone_utils import get_budget_reset_time | |
| def test_get_budget_reset_time(): | |
| """ | |
| Test that the budget reset time is set to the first of the next month | |
| """ | |
| # Get the current date | |
| now = datetime.now(timezone.utc) | |
| # Calculate expected reset date (first of next month) | |
| if now.month == 12: | |
| expected_month = 1 | |
| expected_year = now.year + 1 | |
| else: | |
| expected_month = now.month + 1 | |
| expected_year = now.year | |
| expected_reset_at = datetime(expected_year, expected_month, 1, tzinfo=timezone.utc) | |
| # Verify budget_reset_at is set to first of next month | |
| assert get_budget_reset_time(budget_duration="1mo") == expected_reset_at | |