mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-30 01:52:18 +00:00
test: alias replica_db on remaining prisma test doubles
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
0ae887c1e7
commit
a38cb9bfd4
8 changed files with 13 additions and 8 deletions
|
|
@ -947,9 +947,8 @@ class TestAzureContainerKnownFailureRegressions:
|
|||
file_purpose=ownership.CONTAINER_OBJECT_PURPOSE,
|
||||
unified_object_id=encoded_stored_id,
|
||||
)
|
||||
prisma_client = SimpleNamespace(
|
||||
db=SimpleNamespace(litellm_managedobjecttable=table)
|
||||
)
|
||||
tables = SimpleNamespace(litellm_managedobjecttable=table)
|
||||
prisma_client = SimpleNamespace(db=tables, replica_db=tables)
|
||||
monkeypatch.setattr(
|
||||
ownership,
|
||||
"_get_prisma_client",
|
||||
|
|
|
|||
|
|
@ -1094,7 +1094,8 @@ class TestMCPServerManager:
|
|||
table = SimpleNamespace(
|
||||
find_many=AsyncMock(return_value=[_row(cached.server_id, corrupted), _row("healthy-sibling", stored)])
|
||||
)
|
||||
prisma = SimpleNamespace(db=SimpleNamespace(litellm_mcpservertable=table))
|
||||
tables = SimpleNamespace(litellm_mcpservertable=table)
|
||||
prisma = SimpleNamespace(db=tables, replica_db=tables)
|
||||
monkeypatch.setattr(proxy_server, "prisma_client", prisma)
|
||||
|
||||
with caplog.at_level(logging.DEBUG, logger="LiteLLM"):
|
||||
|
|
|
|||
|
|
@ -106,10 +106,11 @@ def test_list_containers_pages_upstream_until_non_admin_keys_see_their_container
|
|||
monkeypatch.setitem(sys.modules, "litellm.proxy.proxy_server", PROXY_SERVER_STUB)
|
||||
table = AsyncMock()
|
||||
table.find_many.return_value = [SimpleNamespace(model_object_id="container:openai:cntr_owned")]
|
||||
tables = SimpleNamespace(litellm_managedobjecttable=table)
|
||||
monkeypatch.setattr(
|
||||
ownership,
|
||||
"_get_prisma_client",
|
||||
AsyncMock(return_value=SimpleNamespace(db=SimpleNamespace(litellm_managedobjecttable=table))),
|
||||
AsyncMock(return_value=SimpleNamespace(db=tables, replica_db=tables)),
|
||||
)
|
||||
processor_cls = _upstream_pages(
|
||||
monkeypatch,
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ async def test_request_filters_match_accounting_and_paginate_before_projection(
|
|||
from litellm.proxy import proxy_server
|
||||
|
||||
_seed(_cache_postgresql)
|
||||
monkeypatch.setattr(proxy_server, "prisma_client", SimpleNamespace(db=_cache_prisma))
|
||||
monkeypatch.setattr(proxy_server, "prisma_client", SimpleNamespace(db=_cache_prisma, replica_db=_cache_prisma))
|
||||
monkeypatch.setattr(proxy_server, "llm_router", None)
|
||||
expected: Final = tuple(sorted((case.request_id for case in _CASES if case.matches(filter)), reverse=True))
|
||||
async with httpx.AsyncClient(transport=httpx.ASGITransport(app=_app(role)), base_url="http://test") as client:
|
||||
|
|
@ -285,7 +285,7 @@ async def test_cursor_keeps_remaining_requests_once_during_insertions_and_deleti
|
|||
"older-cache-read", {"usage_object": {"cache_read_input_tokens": 100}}, start_time=datetime(2026, 9, 1, 11),
|
||||
))
|
||||
_seed(_cache_postgresql, cases)
|
||||
monkeypatch.setattr(proxy_server, "prisma_client", SimpleNamespace(db=_cache_prisma))
|
||||
monkeypatch.setattr(proxy_server, "prisma_client", SimpleNamespace(db=_cache_prisma, replica_db=_cache_prisma))
|
||||
monkeypatch.setattr(proxy_server, "llm_router", None)
|
||||
expected: Final = (*sorted((case.request_id for case in _CASES if case.matches("all")), reverse=True), "older-cache-read")
|
||||
async with httpx.AsyncClient(
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class _PermissionDb:
|
|||
@dataclass(frozen=True)
|
||||
class _Client:
|
||||
db: _PermissionDb = _PermissionDb()
|
||||
replica_db: _PermissionDb = db
|
||||
|
||||
|
||||
def _team(**updates: object) -> LiteLLM_TeamTable:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ def _table(rows=()):
|
|||
|
||||
|
||||
def _prisma(**tables):
|
||||
return types.SimpleNamespace(db=types.SimpleNamespace(**tables))
|
||||
db = types.SimpleNamespace(**tables)
|
||||
return types.SimpleNamespace(db=db, replica_db=db)
|
||||
|
||||
|
||||
def _config_server(server_id: str, name: str, alias: str | None = None, server_name: str | None = None) -> MCPServer:
|
||||
|
|
|
|||
|
|
@ -653,6 +653,7 @@ def _make_db_attachment_row(
|
|||
def _prisma_with_attachment_rows(rows: list[MagicMock]) -> MagicMock:
|
||||
prisma = MagicMock()
|
||||
prisma.configure_mock(**{"db.litellm_policyattachmenttable.find_many": AsyncMock(return_value=rows)})
|
||||
prisma.replica_db = prisma.db
|
||||
return prisma
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1785,6 +1785,7 @@ async def test_update_data_key_branch_stamps_settings_updated_at():
|
|||
client = MagicMock()
|
||||
client.jsonify_object = MagicMock(side_effect=lambda data: dict(data))
|
||||
client.db.litellm_verificationtoken.update = AsyncMock(return_value=None)
|
||||
client.replica_db = client.db
|
||||
|
||||
before = datetime.now(timezone.utc)
|
||||
await PrismaClient.update_data(client, token="sk-test-key", data={"models": ["gpt-4"]})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue