test(prompts): isolate in-memory version tests

This commit is contained in:
user
2026-04-14 23:37:13 +00:00
parent f521e27371
commit b1bc3c166d
@@ -247,8 +247,10 @@ class TestPromptVersionsEndpoint:
),
}
# Mock the IN_MEMORY_PROMPT_REGISTRY at the import location
with patch("litellm.proxy.prompts.prompt_registry.IN_MEMORY_PROMPT_REGISTRY") as mock_registry:
# Force the in-memory path so this test is isolated from any leaked prisma mocks.
with patch("litellm.proxy.proxy_server.prisma_client", None), patch(
"litellm.proxy.prompts.prompt_registry.IN_MEMORY_PROMPT_REGISTRY"
) as mock_registry:
mock_registry.IN_MEMORY_PROMPTS = mock_prompts
# Test with base prompt ID
@@ -293,7 +295,9 @@ class TestPromptVersionsEndpoint:
user_role=LitellmUserRoles.PROXY_ADMIN
)
with patch("litellm.proxy.prompts.prompt_registry.IN_MEMORY_PROMPT_REGISTRY") as mock_registry:
with patch("litellm.proxy.proxy_server.prisma_client", None), patch(
"litellm.proxy.prompts.prompt_registry.IN_MEMORY_PROMPT_REGISTRY"
) as mock_registry:
mock_registry.IN_MEMORY_PROMPTS = {}
with pytest.raises(HTTPException) as exc_info:
@@ -304,4 +308,3 @@ class TestPromptVersionsEndpoint:
assert exc_info.value.status_code == 404
assert "No versions found" in exc_info.value.detail