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]

573 B
Raw Blame
"""An ``AsyncMock`` standing in for a ``prisma_client.db`` method that reached the engine,
marking the DB I/O witness the way ``_TrackedPrismaEngine`` does, so the producer under test
emits its service event."""

from typing import TypeVar
from unittest.mock import AsyncMock

from litellm.proxy.db.log_db_metrics import record_db_io

_T = TypeVar("_T")


def engine_call(return_value: _T | None = None) -> AsyncMock:
    async def run(*args: object, **kwargs: object) -> _T | None:
        record_db_io()
        return return_value

    return AsyncMock(side_effect=run)