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

Function _mock_deployment

tests/lib/test_credentials.py:2421–2427  ·  view source on GitHub ↗

Mock one deployment: its token endpoint mints `token` and its messages endpoint accepts anything. Pair with `_requests_to` to check that a client only ever talks to (and presents tokens from) the deployment it was built for.

(respx_mock: MockRouter, base_url: str, token: str)

Source from the content-addressed store, hash-verified

2419
2420
2421def _mock_deployment(respx_mock: MockRouter, base_url: str, token: str) -> None:
2422 """Mock one deployment: its token endpoint mints `token` and its
2423 messages endpoint accepts anything. Pair with `_requests_to` to
2424 check that a client only ever talks to (and presents tokens from) the
2425 deployment it was built for."""
2426 _mock_token_exchange(respx_mock, base_url, token)
2427 respx_mock.post(f"{base_url}/v1/messages").mock(return_value=_message_response())
2428
2429
2430def _requests_to(respx_mock: MockRouter, base_url: str) -> List[httpx2.Request]:

Calls 3

_mock_token_exchangeFunction · 0.85
_message_responseFunction · 0.85
postMethod · 0.45

Tested by

no test coverage detected