This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import sys
|
||||
from typing import Any
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -124,6 +126,35 @@ def test_anthropic_tool_calling_client_includes_image_block_when_screenshot_pres
|
||||
assert content[1] == {"type": "text", "text": "user"}
|
||||
|
||||
|
||||
def test_anthropic_tool_calling_client_passes_custom_base_url_to_sdk(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
constructed: list[dict[str, Any]] = []
|
||||
|
||||
class RecordingAnthropic:
|
||||
def __init__(self, **kwargs: str) -> None:
|
||||
constructed.append(kwargs)
|
||||
|
||||
monkeypatch.setitem(
|
||||
sys.modules,
|
||||
"anthropic",
|
||||
SimpleNamespace(Anthropic=RecordingAnthropic),
|
||||
)
|
||||
client = AnthropicToolCallingClient(
|
||||
model="test-model",
|
||||
api_key="managed-api-key",
|
||||
base_url="https://anthropic-proxy.example",
|
||||
)
|
||||
|
||||
assert isinstance(client._client(), RecordingAnthropic)
|
||||
assert constructed == [
|
||||
{
|
||||
"api_key": "managed-api-key",
|
||||
"base_url": "https://anthropic-proxy.example",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def test_anthropic_tool_calling_client_wraps_transport_errors() -> None:
|
||||
messages = FakeMessages(error=TimeoutError("timed out"))
|
||||
client = AnthropicToolCallingClient(model="test-model", transport=FakeTransport(messages))
|
||||
|
||||
Reference in New Issue
Block a user