MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / test_api_key_request

Function test_api_key_request

tests/lib/test_aws.py:419–435  ·  view source on GitHub ↗
(respx_mock: MockRouter)

Source from the content-addressed store, hash-verified

417@pytest.mark.filterwarnings("ignore::DeprecationWarning")
418@pytest.mark.respx()
419def 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")

Callers

nothing calls this directly

Calls 3

AnthropicAWSClass · 0.90
postMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected