mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
test(proxy): a mocked request is not an Anthropic caller
Agent: shiqing-desktop-085b2e
This commit is contained in:
parent
a1dc3507e8
commit
f7c145ade1
1 changed files with 12 additions and 0 deletions
|
|
@ -7,6 +7,8 @@ event and is skipped, so a failure delivered that way never reaches the caller.
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import cast
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from starlette.requests import Request
|
||||
|
|
@ -33,6 +35,16 @@ def test_openai_paths_are_left_alone() -> None:
|
|||
assert not _streams_anthropic_events(None)
|
||||
|
||||
|
||||
def test_a_request_without_a_real_path_is_not_anthropic() -> None:
|
||||
"""A mocked or partial request must not be read as an Anthropic caller."""
|
||||
|
||||
class _MockedRequest:
|
||||
url = MagicMock()
|
||||
|
||||
assert not _streams_anthropic_events(cast(Request, _MockedRequest()))
|
||||
assert not _streams_anthropic_events(cast(Request, MagicMock()))
|
||||
|
||||
|
||||
def test_anthropic_frame_is_an_error_event_without_done() -> None:
|
||||
frames = _anthropic_sse_error_frames({"message": "boom", "type": "internal_server_error", "code": "500"})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue