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

Function test_api_key_request_async

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

Source from the content-addressed store, hash-verified

439@pytest.mark.respx()
440@pytest.mark.asyncio()
441async def test_api_key_request_async(respx_mock: MockRouter) -> None:
442 respx_mock.post(re.compile(r"https://aws-external-anthropic\.us-east-1\.api\.aws/.*")).mock(
443 return_value=httpx2.Response(200, json={"foo": "bar"})
444 )
445
446 client = AsyncAnthropicAWS(api_key="test-key", aws_region="us-east-1", workspace_id="ws-123")
447 await client.messages.create(
448 max_tokens=1024,
449 messages=[{"role": "user", "content": "Hello"}],
450 model="claude-sonnet-4-20250514",
451 )
452
453 calls = cast("list[MockRequestCall]", respx_mock.calls)
454 assert len(calls) == 1
455 assert str(calls[0].request.url) == "https://aws-external-anthropic.us-east-1.api.aws/v1/messages"
456 assert calls[0].request.headers["Authorization"] == "Bearer test-key"
457 assert "X-Api-Key" not in calls[0].request.headers
458
459
460@pytest.mark.filterwarnings("ignore::DeprecationWarning")

Callers

nothing calls this directly

Calls 3

AsyncAnthropicAWSClass · 0.90
postMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected