fix(ci): resolve 4 CI test failures

1. Add CURSOR_API_BASE to environment variables reference in config_settings.md
2. Fix test_sse_mcp_handler_mock by mocking extract_mcp_auth_context and
   set_auth_context so the handler reaches sse_session_manager.handle_request
3. Change test_async_increment_tokens_with_ttl_preservation flaky decorator
   from reruns=3 to retries=3,delay=2 for better intermittent failure handling
4. Add app.dependency_overrides for user_api_key_auth in test_mock_create_audio_file
   to bypass authentication (same pattern as test_target_storage_invokes_storage_backend)

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-02-28 23:24:25 +00:00
parent a3376b60f2
commit 863d07011f
4 changed files with 70 additions and 42 deletions

View file

@ -488,6 +488,7 @@ router_settings:
| CONFIDENT_API_KEY | API key for Confident AI (Deepeval) Logging service
| COHERE_API_BASE | Base URL for Cohere API. Default is https://api.cohere.com
| COMPETITOR_LLM_TEMPERATURE | Temperature setting for the LLM used in competitor discovery. Default is 0.3
| CURSOR_API_BASE | API base URL for Cursor AI provider integration. Default is https://api.cursor.com
| DATABASE_HOST | Hostname for the database server
| DATABASE_NAME | Name of the database
| DATABASE_PASSWORD | Password for the database user

View file

@ -437,6 +437,7 @@ async def test_streamable_http_mcp_handler_mock():
@pytest.mark.asyncio
async def test_sse_mcp_handler_mock():
"""Test the SSE MCP handler functionality"""
from litellm.proxy._types import UserAPIKeyAuth
# Mock the SSE session manager and its methods
mock_sse_session_manager = AsyncMock()
@ -455,12 +456,26 @@ async def test_sse_mcp_handler_mock():
mock_receive = AsyncMock()
mock_send = AsyncMock()
mock_auth_result = (
UserAPIKeyAuth(),
None,
None,
{},
{},
[],
)
with patch(
"litellm.proxy._experimental.mcp_server.server._SESSION_MANAGERS_INITIALIZED",
True,
), patch(
"litellm.proxy._experimental.mcp_server.server.sse_session_manager",
mock_sse_session_manager,
), patch(
"litellm.proxy._experimental.mcp_server.server.extract_mcp_auth_context",
new=AsyncMock(return_value=mock_auth_result),
), patch(
"litellm.proxy._experimental.mcp_server.server.set_auth_context",
):
from litellm.proxy._experimental.mcp_server.server import handle_sse_mcp

View file

@ -1116,7 +1116,7 @@ async def test_dynamic_rate_limiting_v3():
), "RPM limit should be enforced when dynamic mode and failures detected"
@pytest.mark.flaky(reruns=3)
@pytest.mark.flaky(retries=3, delay=2)
@pytest.mark.asyncio
async def test_async_increment_tokens_with_ttl_preservation():
"""

View file

@ -107,8 +107,13 @@ def test_mock_create_audio_file(mocker: MockerFixture, monkeypatch, llm_router:
"""
import litellm
from litellm import Router
from litellm.proxy._types import LitellmUserRoles
import litellm.proxy.proxy_server as ps
from litellm.proxy.utils import ProxyLogging
monkeypatch.setattr("litellm.proxy.proxy_server.master_key", None)
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", None)
# Mock create_file as an async function
mock_create_file = mocker.patch("litellm.files.main.create_file", new=mocker.AsyncMock())
@ -178,52 +183,59 @@ def test_mock_create_audio_file(mocker: MockerFixture, monkeypatch, llm_router:
"litellm.proxy.proxy_server.proxy_logging_obj", proxy_logging_obj
)
# Create a simple test file content
test_file_content = b"test audio content"
test_file = ("test.wav", test_file_content, "audio/wav")
response = client.post(
"/v1/files",
files={"file": test_file},
data={
"purpose": "user_data",
"target_model_names": "azure-gpt-3-5-turbo, gpt-3.5-turbo",
},
headers={"Authorization": "Bearer test-key"},
app.dependency_overrides[ps.user_api_key_auth] = lambda: UserAPIKeyAuth(
user_role=LitellmUserRoles.PROXY_ADMIN, user_id="test-user"
)
assert response.status_code == 200
try:
# Create a simple test file content
test_file_content = b"test audio content"
test_file = ("test.wav", test_file_content, "audio/wav")
# Get all calls made to create_file
calls = mock_create_file.call_args_list
response = client.post(
"/v1/files",
files={"file": test_file},
data={
"purpose": "user_data",
"target_model_names": "azure-gpt-3-5-turbo, gpt-3.5-turbo",
},
headers={"Authorization": "Bearer test-key"},
)
# Check for Azure call
azure_call_found = False
for call in calls:
kwargs = call.kwargs
if (
kwargs.get("custom_llm_provider") == "azure"
and kwargs.get("model") == "azure/chatgpt-v-2"
and kwargs.get("api_key") == "azure_api_key"
):
azure_call_found = True
break
assert (
azure_call_found
), f"Azure call not found with expected parameters. Calls: {calls}"
assert response.status_code == 200
# Check for OpenAI call
openai_call_found = False
for call in calls:
kwargs = call.kwargs
if (
kwargs.get("custom_llm_provider") == "openai"
and kwargs.get("model") == "openai/gpt-3.5-turbo"
and kwargs.get("api_key") == "openai_api_key"
):
openai_call_found = True
break
assert openai_call_found, "OpenAI call not found with expected parameters"
# Get all calls made to create_file
calls = mock_create_file.call_args_list
# Check for Azure call
azure_call_found = False
for call in calls:
kwargs = call.kwargs
if (
kwargs.get("custom_llm_provider") == "azure"
and kwargs.get("model") == "azure/chatgpt-v-2"
and kwargs.get("api_key") == "azure_api_key"
):
azure_call_found = True
break
assert (
azure_call_found
), f"Azure call not found with expected parameters. Calls: {calls}"
# Check for OpenAI call
openai_call_found = False
for call in calls:
kwargs = call.kwargs
if (
kwargs.get("custom_llm_provider") == "openai"
and kwargs.get("model") == "openai/gpt-3.5-turbo"
and kwargs.get("api_key") == "openai_api_key"
):
openai_call_found = True
break
assert openai_call_found, "OpenAI call not found with expected parameters"
finally:
app.dependency_overrides.pop(ps.user_api_key_auth, None)
@pytest.mark.flaky(retries=3, delay=2)