MCPcopy
hub / github.com/openai/openai-python / test_bedrock_region_precedence

Function test_bedrock_region_precedence

tests/lib/test_bedrock.py:205–223  ·  view source on GitHub ↗
(client_cls: type[Client])

Source from the content-addressed store, hash-verified

203
204@pytest.mark.parametrize("client_cls", [BedrockOpenAI, AsyncBedrockOpenAI])
205def test_bedrock_region_precedence(client_cls: type[Client]) -> None:
206 with update_env(AWS_BEDROCK_BASE_URL=Omit(), AWS_REGION="us-east-1", AWS_DEFAULT_REGION="us-west-2"):
207 explicit_region_client = (
208 make_sync_client(aws_region="eu-west-1", api_key="token")
209 if client_cls is BedrockOpenAI
210 else make_async_client(aws_region="eu-west-1", api_key="token")
211 )
212 aws_region_client = (
213 make_sync_client(api_key="token") if client_cls is BedrockOpenAI else make_async_client(api_key="token")
214 )
215
216 with update_env(AWS_BEDROCK_BASE_URL=Omit(), AWS_REGION=Omit(), AWS_DEFAULT_REGION="us-west-2"):
217 default_region_client = (
218 make_sync_client(api_key="token") if client_cls is BedrockOpenAI else make_async_client(api_key="token")
219 )
220
221 assert explicit_region_client.base_url == URL("https://bedrock-mantle.eu-west-1.api.aws/openai/v1/")
222 assert aws_region_client.base_url == URL("https://bedrock-mantle.us-east-1.api.aws/openai/v1/")
223 assert default_region_client.base_url == URL("https://bedrock-mantle.us-west-2.api.aws/openai/v1/")
224
225
226@pytest.mark.parametrize("client_cls", [BedrockOpenAI, AsyncBedrockOpenAI])

Callers

nothing calls this directly

Calls 4

update_envFunction · 0.90
OmitClass · 0.90
make_sync_clientFunction · 0.85
make_async_clientFunction · 0.85

Tested by

no test coverage detected