The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(proxy): parametrize the stale end-user counter case so no Final local sits in a loop
mateo-berri4ffd2ffb2501
diff --git a/tests/test_litellm/proxy/proxy_server/test_spend_counters.py b/tests/test_litellm/proxy/proxy_server/test_spend_counters.pyindex ef6f8120c82..86e97a334df 100644--- a/tests/test_litellm/proxy/proxy_server/test_spend_counters.py+++ b/tests/test_litellm/proxy/proxy_server/test_spend_counters.py@@ -223,24 +223,24 @@ async def test_get_current_spend_floor_caches_db_read(monkeypatch):@pytest.mark.asyncio-async def test_get_current_spend_floors_end_user_tag_against_fallback(monkeypatch):[email protected]("counter_key", ("spend:end_user:e1", "spend:tag:t1"))+async def test_get_current_spend_floors_end_user_tag_against_fallback(monkeypatch, counter_key):"""Tag counters have no DB row (from_db returns None), and an end-user counter hasnone to read without a DB client. When such a counter is stale-low, enforcementfalls back to the caller's recorded spend (loaded fresh in auth) instead oftrusting the stale counter."""- fake_cache = _make_spend_counter_cache(redis_get_value=2.0)+ fake_cache: Final = _make_spend_counter_cache(redis_get_value=2.0)monkeypatch.setattr(ps, "spend_counter_cache", fake_cache)monkeypatch.setattr(ps, "prisma_client", None)monkeypatch.setattr(ps.SpendCounterReseed, "from_db", AsyncMock(return_value=None))- for counter_key in ("spend:end_user:e1", "spend:tag:t1"):- result: Final = await ps.get_current_spend(- counter_key=counter_key,- fallback_spend=20.0,- max_budget=10.0,- )+ result: Final = await ps.get_current_spend(+ counter_key=counter_key,+ fallback_spend=20.0,+ max_budget=10.0,+ )- assert result == 20.0+ assert result == 20.0# no DB row to repair against, so the shared counter is left untouchedfake_cache.redis_cache.async_set_max.assert_not_called()