Skip to content

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]

test(mcp): give the new cache and tombstone patches TQ008 reasons and match the keyword eviction call

yassince48a3fbcce7
diff --git a/tests/mcp_tests/test_per_user_oauth_cache.py b/tests/mcp_tests/test_per_user_oauth_cache.py
index 141b906fce9..ac453df8fa5 100644
--- a/tests/mcp_tests/test_per_user_oauth_cache.py
+++ b/tests/mcp_tests/test_per_user_oauth_cache.py
@@ -331,9 +331,7 @@ class TestMCPPerUserTokenCache:
with patch("litellm.proxy.proxy_server.user_api_key_cache", mock_dual_cache):
await cache.delete("alice", "slack-test")
- mock_dual_cache.async_delete_cache.assert_called_once_with(
- "mcp:per_user_token:alice:slack-test"
- )
+ mock_dual_cache.async_delete_cache.assert_called_once_with(key="mcp:per_user_token:alice:slack-test")
mock_dual_cache.async_set_cache.assert_not_called()
@pytest.mark.asyncio
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_byok_oauth_endpoints.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_byok_oauth_endpoints.py
index df0d7916baf..87e23893616 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_byok_oauth_endpoints.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_byok_oauth_endpoints.py
@@ -692,9 +692,15 @@ async def test_invalidate_byok_cred_cache_evicts_locally_and_broadcasts_the_same
publish = AsyncMock()
with (
- patch("litellm.proxy._experimental.mcp_server.db.get_user_credential", new=db_lookup),
- patch("litellm.proxy.proxy_server.prisma_client", MagicMock()),
- patch.object(server_module, "publish_auth_cache_invalidation", new=publish),
+ patch( # test-quality-ok: the DB row lookup is the only seam below the credential resolver; no Prisma fake exists
+ "litellm.proxy._experimental.mcp_server.db.get_user_credential", new=db_lookup
+ ),
+ patch( # test-quality-ok: the resolver reads the module-level prisma_client singleton; the suite's only seam
+ "litellm.proxy.proxy_server.prisma_client", MagicMock()
+ ),
+ patch.object( # test-quality-ok: the redis publisher is module-level; asserting the broadcast without a redis
+ server_module, "publish_auth_cache_invalidation", new=publish
+ ),
):
assert await server_module._get_byok_credential(server, user_auth) == "sk-before-revoke"
assert await server_module._get_byok_credential(server, user_auth) == "sk-before-revoke"
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
index f496f22d5d2..0e2ceb98987 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server.py
@@ -3078,7 +3078,9 @@ async def test_admin_terminated_session_id_stays_refused_while_replayed_and_is_f
"method": "POST",
"headers": [(b"content-type", b"application/json"), (b"mcp-session-id", session_id.encode())],
}
- with patch.object(mcp_server.time, "monotonic", return_value=now):
+ with patch.object( # test-quality-ok: the stale-session handler reads the clock directly; no injectable now
+ mcp_server.time, "monotonic", return_value=now
+ ):
handled = await mcp_server._handle_stale_mcp_session(
scope, AsyncMock(), AsyncMock(), session_manager_stateful
)
@@ -3099,7 +3101,9 @@ async def test_admin_terminated_session_id_stays_refused_while_replayed_and_is_f
mcp_server._stateful_session_auth_context_last_seen, {}, clear=True
),
):
- with patch.object(mcp_server.time, "monotonic", return_value=1000.0):
+ with patch.object( # test-quality-ok: termination stamps the tombstone from the clock directly; no injectable now
+ mcp_server.time, "monotonic", return_value=1000.0
+ ):
closed = await mcp_server.terminate_mcp_gateway_sessions(user_id="alice")
assert closed.terminated_sessions == 2
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_oauth2_token_cache.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_oauth2_token_cache.py
index 301b3887922..30d0f17a099 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_oauth2_token_cache.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_oauth2_token_cache.py
@@ -409,8 +409,10 @@ async def test_per_user_token_delete_evicts_locally_and_broadcasts_to_peer_worke
local_cache.in_memory_cache.set_cache(key, "encrypted-token")
with (
- patch.object(proxy_server, "user_api_key_cache", local_cache),
- patch(
+ patch.object( # test-quality-ok: the token cache reads the module-level user_api_key_cache singleton; the suite's only seam
+ proxy_server, "user_api_key_cache", local_cache
+ ),
+ patch( # test-quality-ok: the redis publisher is module-level; asserting the broadcast without a redis
"litellm.proxy.common_utils.auth_cache_invalidation_pubsub.publish_auth_cache_invalidation",
new=publish,
),