From a59dcfd9613fa0f5263c5d3b175d55b308877f69 Mon Sep 17 00:00:00 2001 From: Jonathan Wrede Date: Sun, 10 May 2026 19:49:41 +0000 Subject: [PATCH] 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. --- tests/proxy_unit_tests/test_user_api_key_auth.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/proxy_unit_tests/test_user_api_key_auth.py b/tests/proxy_unit_tests/test_user_api_key_auth.py index 210347aaf94..6cfe52e9cc8 100644 --- a/tests/proxy_unit_tests/test_user_api_key_auth.py +++ b/tests/proxy_unit_tests/test_user_api_key_auth.py @@ -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"])