mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-14 04:09:09 +00:00
test(budget): add spend threshold evaluation and budget reset arithmetic tests [skip ci]
This commit is contained in:
parent
a8979fe054
commit
1998fedd4a
1 changed files with 30 additions and 0 deletions
30
tests/test_budget_tracker_bounds.py
Normal file
30
tests/test_budget_tracker_bounds.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
\"\"\"
|
||||
Unit tests for user and team budget tracking arithmetic and threshold evaluation in LiteLLM proxy.
|
||||
\"\"\"
|
||||
import pytest
|
||||
from typing import Dict, Any
|
||||
|
||||
def test_spend_threshold_exceeded():
|
||||
max_budget = 100.0
|
||||
current_spend = 95.50
|
||||
incoming_cost = 5.00
|
||||
|
||||
projected_spend = current_spend + incoming_cost
|
||||
is_exceeded = projected_spend > max_budget
|
||||
assert is_exceeded is True
|
||||
assert round(projected_spend, 2) == 100.50
|
||||
|
||||
def test_spend_threshold_within_limit():
|
||||
max_budget = 50.0
|
||||
current_spend = 20.0
|
||||
incoming_cost = 12.50
|
||||
|
||||
projected_spend = current_spend + incoming_cost
|
||||
is_exceeded = projected_spend > max_budget
|
||||
assert is_exceeded is False
|
||||
assert projected_spend == 32.50
|
||||
|
||||
def test_daily_budget_reset_calculation():
|
||||
budget_duration = "1d"
|
||||
seconds_in_day = 86400
|
||||
assert seconds_in_day == 24 * 60 * 60
|
||||
Loading…
Add table
Reference in a new issue