fix: update test to match new user budget behavior for team keys

The test previously expected team keys to bypass user budget checks.
Since the whole point of this change is to enforce user budgets for
team-associated keys, update the test expectation accordingly.

Also revert unrelated 403->401 status code changes that were in the
base branch when this was created.
This commit is contained in:
Jonathan Wrede 2026-05-10 19:49:41 +00:00
parent fe2b2a5c55
commit a59dcfd961

View file

@ -219,8 +219,9 @@ async def test_aaauser_personal_budgets(key_ownership):
"""
Set a personal budget on a user
- have it only apply when key belongs to user -> raises BudgetExceededError
- if key belongs to team, have key respect team budget -> allows call to go through
- user_key: raises BudgetExceededError when user is over personal budget
- team_key: also raises BudgetExceededError -- user budget is enforced
regardless of team membership
"""
import asyncio
import time
@ -273,15 +274,9 @@ async def test_aaauser_personal_budgets(key_ownership):
== valid_token
)
try:
with pytest.raises(Exception):
await user_api_key_auth(request=request, api_key="Bearer " + user_key)
if key_ownership == "user_key":
pytest.fail("Expected this call to fail. User is over limit.")
except Exception:
if key_ownership == "team_key":
pytest.fail("Expected this call to work. Key is below team budget.")
@pytest.mark.asyncio
@pytest.mark.parametrize("prohibited_param", ["api_base", "base_url"])