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

Function test_api_key_auth

tests/lib/test_bedrock.py:407–420  ·  view source on GitHub ↗
(respx_mock: MockRouter)

Source from the content-addressed store, hash-verified

405
406@pytest.mark.respx()
407def test_api_key_auth(respx_mock: MockRouter) -> None:
408 respx_mock.post(re.compile(r"https://bedrock-runtime\.us-east-1\.amazonaws\.com/model/.*/invoke")).mock(
409 return_value=httpx2.Response(200, json={"foo": "bar"}),
410 )
411
412 sync_api_key_client.messages.create(
413 max_tokens=1024,
414 messages=[{"role": "user", "content": "Say hello there!"}],
415 model="anthropic.claude-3-5-sonnet-20241022-v2:0",
416 )
417
418 calls = cast("list[MockRequestCall]", respx_mock.calls)
419 assert len(calls) == 1
420 assert calls[0].request.headers["Authorization"] == "Bearer test-api-key"
421
422
423@pytest.mark.respx()

Callers

nothing calls this directly

Calls 2

postMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected