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]

fix(tests): mock prisma.Prisma in backoff retry tests to avoid 'prisma generate'

Julio Quinteros Prodefc76b32a6c
diff --git a/tests/proxy_unit_tests/test_prisma_client_backoff_retry.py b/tests/proxy_unit_tests/test_prisma_client_backoff_retry.py
index ca0519f0d96..b49bef3632d 100644
--- a/tests/proxy_unit_tests/test_prisma_client_backoff_retry.py
+++ b/tests/proxy_unit_tests/test_prisma_client_backoff_retry.py
@@ -22,6 +22,20 @@ import httpx
import backoff
[email protected](autouse=True)
+def mock_prisma_binary():
+ """Mock prisma.Prisma to avoid requiring 'prisma generate' in CI.
+
+ PrismaClient.__init__ does `from prisma import Prisma` inline, which raises
+ RuntimeError when the Prisma client hasn't been generated yet. Replacing
+ sys.modules['prisma'] with a MagicMock lets the import succeed so tests can
+ instantiate a real PrismaClient and override client.db with their own mocks.
+ """
+ mock_module = MagicMock()
+ with patch.dict(sys.modules, {"prisma": mock_module}):
+ yield
+
+
@pytest.fixture
def mock_prisma_client():
"""Create a mock PrismaClient with necessary attributes"""