mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
* test(integration): exact four-part translation cases on a shared fake provider and shared YAML deployment Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(integration): compare every non-transport provider header and check for late provider requests at session end Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(integration): name TranslationTestCase fields after litellm and provider sides and drop regressions Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(integration): prefix checked TranslationTestCase fields with expected_ and name the fake reply mock_provider_response Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs(integration): name TranslationTestCase fields in the translation README Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(integration): add a claude-opus-5-5 base case and deployment next to claude-sonnet-4-6 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(integration): name translation cases <MODEL>_TEST_CASE and document the naming rule Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs(integration): move translation test rules into tests/integration/translation Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: kerry <kerry@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""The fake provider shared by every integration test that takes the `provider` fixture.
|
|
|
|
Deployments in `proxy_config.yaml` point at `PROVIDER_URL`, so one server answers for all of them. A test
|
|
queues the replies it expects with `expect` and reads what the proxy sent with `received`. Tests run one at a
|
|
time against it; the `provider` fixture checks nothing is left over between tests.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections import deque
|
|
from collections.abc import Iterator
|
|
from contextlib import contextmanager
|
|
from dataclasses import dataclass, field
|
|
from typing import Final
|
|
|
|
from tests.integration._support.wire import Reply, Request, Wire, wire_server
|
|
|
|
PROVIDER_PORT: Final = 8191
|
|
PROVIDER_URL: Final = f"http://127.0.0.1:{PROVIDER_PORT}"
|
|
_UNQUEUED: Final = Reply(status=500, body=b'{"error": "the shared fake provider has no reply queued for this request"}')
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class SharedProvider:
|
|
wire: Wire
|
|
replies: deque[Reply]
|
|
last_test: str | None = field(default=None)
|
|
|
|
def expect(self, *replies: Reply) -> None:
|
|
self.replies.extend(replies)
|
|
|
|
def received(self) -> tuple[Request, ...]:
|
|
return self.wire.drain()
|
|
|
|
|
|
@contextmanager
|
|
def shared_provider() -> Iterator[SharedProvider]:
|
|
replies: Final[deque[Reply]] = deque()
|
|
|
|
def respond(request: Request) -> Reply:
|
|
return replies.popleft() if replies else _UNQUEUED
|
|
|
|
with wire_server(respond, port=PROVIDER_PORT) as wire:
|
|
yield SharedProvider(wire, replies)
|