From b6557d2b14f77204548177ff9295f5335365b653 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Tue, 4 Aug 2026 16:07:02 -0700 Subject: [PATCH] test: repair three failing suites on litellm_internal_staging The management route-coverage guard fires because /team/metadata_schema landed in #33353 without a behavior-suite scenario, so this adds one covering the nine seeded actors plus the unauthenticated 401 The prometheus budget-metric assertions read the log call's first positional arg, which #35703 turned into an unrendered "%s" format string when it moved logging to lazy args. They now render the message from the call args, which also pins the arg order and the exception text that the old substring check never reached GitHub Models was fully retired on 2026-07-30, so test_completion_github_api can no longer pass: the endpoint the github provider targets returns 404 and models.github.ai answers 410 "github_models_retirement_brownout". The dead live test is removed rather than skipped --- .../test_prometheus_logging_callbacks.py | 30 +++++++------------ tests/local_testing/test_completion.py | 30 ------------------- .../management/test_team_metadata_schema.py | 25 ++++++++++++++++ 3 files changed, 35 insertions(+), 50 deletions(-) create mode 100644 tests/proxy_behavior/management/test_team_metadata_schema.py diff --git a/tests/enterprise/litellm_enterprise/enterprise_callbacks/test_prometheus_logging_callbacks.py b/tests/enterprise/litellm_enterprise/enterprise_callbacks/test_prometheus_logging_callbacks.py index 9acb87750e9..b6c9cd0294b 100644 --- a/tests/enterprise/litellm_enterprise/enterprise_callbacks/test_prometheus_logging_callbacks.py +++ b/tests/enterprise/litellm_enterprise/enterprise_callbacks/test_prometheus_logging_callbacks.py @@ -1741,26 +1741,16 @@ async def test_initialize_remaining_budget_metrics_exception_handling( # Verify all five errors were logged (teams, keys, users, orgs, and user/team count) assert mock_logger.call_count == 5 - assert ( - "Error initializing teams budget metrics" - in mock_logger.call_args_list[0][0][0] - ) - assert ( - "Error initializing keys budget metrics" - in mock_logger.call_args_list[1][0][0] - ) - assert ( - "Error initializing users budget metrics" - in mock_logger.call_args_list[2][0][0] - ) - assert ( - "Error initializing orgs budget metrics" - in mock_logger.call_args_list[3][0][0] - ) - assert ( - "Error initializing user/team count metrics" - in mock_logger.call_args_list[4][0][0] - ) + logged = [ + call.args[0] % call.args[1:] for call in mock_logger.call_args_list + ] + assert logged == [ + "Error initializing teams budget metrics: Database error", + "Error initializing keys budget metrics: Key listing error", + "Error initializing users budget metrics: User database error", + "Error initializing orgs budget metrics: Org database error", + "Error initializing user/team count metrics: User count error", + ] # Verify the metrics were never called prometheus_logger.litellm_remaining_team_budget_metric.assert_not_called() diff --git a/tests/local_testing/test_completion.py b/tests/local_testing/test_completion.py index 616d8b94e6a..b4f0359cf9d 100644 --- a/tests/local_testing/test_completion.py +++ b/tests/local_testing/test_completion.py @@ -213,36 +213,6 @@ def test_completion_empower(): pytest.fail(f"Error occurred: {e}") -def test_completion_github_api(): - litellm.set_verbose = True - messages = [ - { - "role": "user", - "content": "\nWhat is the query for `console.log` => `console.error`\n", - }, - { - "role": "assistant", - "content": "\nThis is the GritQL query for the given before/after examples:\n\n`console.log` => `console.error`\n\n", - }, - { - "role": "user", - "content": "\nWhat is the query for `console.info` => `consdole.heaven`\n", - }, - ] - try: - # test without max tokens - response = completion( - model="github/gpt-4o", - messages=messages, - ) - # Add any assertions, here to check response args - print(response) - except litellm.AuthenticationError: - pass - except Exception as e: - pytest.fail(f"Error occurred: {e}") - - def test_completion_claude_3_empty_response(): litellm.set_verbose = True diff --git a/tests/proxy_behavior/management/test_team_metadata_schema.py b/tests/proxy_behavior/management/test_team_metadata_schema.py new file mode 100644 index 00000000000..c1d308eba33 --- /dev/null +++ b/tests/proxy_behavior/management/test_team_metadata_schema.py @@ -0,0 +1,25 @@ +"""GET /team/metadata_schema — the behavior world declares no +``general_settings.team_metadata_schema``, so the route is an info route that +returns an empty field list to every authenticated actor and 401s without a key. +""" + +import pytest + +from .actors import Actor + +pytestmark = pytest.mark.asyncio(loop_scope="session") + + +@pytest.mark.parametrize("actor", list(Actor), ids=[a.value for a in Actor]) +async def test_team_metadata_schema_default_is_empty(actor: Actor, proxy_client, world): + resp = await proxy_client.get( + "/team/metadata_schema", + headers={"Authorization": f"Bearer {world.keys[actor].cleartext}"}, + ) + assert resp.status_code == 200, f"{actor.value}: {resp.status_code} {resp.text}" + assert resp.json() == {"fields": []} + + +async def test_team_metadata_schema_requires_auth(proxy_client, world): + resp = await proxy_client.get("/team/metadata_schema") + assert resp.status_code == 401, resp.text