(respx_mock: MockRouter)
| 417 | @pytest.mark.filterwarnings("ignore::DeprecationWarning") |
| 418 | @pytest.mark.respx() |
| 419 | def test_api_key_request(respx_mock: MockRouter) -> None: |
| 420 | respx_mock.post(re.compile(r"https://aws-external-anthropic\.us-east-1\.api\.aws/.*")).mock( |
| 421 | return_value=httpx2.Response(200, json={"foo": "bar"}) |
| 422 | ) |
| 423 | |
| 424 | client = AnthropicAWS(api_key="test-key", aws_region="us-east-1", workspace_id="ws-123") |
| 425 | client.messages.create( |
| 426 | max_tokens=1024, |
| 427 | messages=[{"role": "user", "content": "Hello"}], |
| 428 | model="claude-sonnet-4-20250514", |
| 429 | ) |
| 430 | |
| 431 | calls = cast("list[MockRequestCall]", respx_mock.calls) |
| 432 | assert len(calls) == 1 |
| 433 | assert str(calls[0].request.url) == "https://aws-external-anthropic.us-east-1.api.aws/v1/messages" |
| 434 | assert calls[0].request.headers["Authorization"] == "Bearer test-key" |
| 435 | assert "X-Api-Key" not in calls[0].request.headers |
| 436 | |
| 437 | |
| 438 | @pytest.mark.filterwarnings("ignore::DeprecationWarning") |
nothing calls this directly
no test coverage detected