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

Method test_azure_api_key_redacted

tests/lib/test_azure.py:317–333  ·  view source on GitHub ↗
(self, respx_mock: MockRouter, caplog: pytest.LogCaptureFixture)

Source from the content-addressed store, hash-verified

315
316 @pytest.mark.respx()
317 def test_azure_api_key_redacted(self, respx_mock: MockRouter, caplog: pytest.LogCaptureFixture) -> None:
318 respx_mock.post(
319 "https://example-resource.azure.openai.com/openai/deployments/gpt-4/chat/completions?api-version=2024-06-01"
320 ).mock(return_value=httpx.Response(200, json={"model": "gpt-4"}))
321
322 client = AzureOpenAI(
323 api_version="2024-06-01",
324 api_key="example_api_key",
325 azure_endpoint="https://example-resource.azure.openai.com",
326 )
327
328 with caplog.at_level(logging.DEBUG):
329 client.chat.completions.create(messages=[], model="gpt-4")
330
331 for record in caplog.records:
332 if is_dict(record.args) and record.args.get("headers") and is_dict(record.args["headers"]):
333 assert record.args["headers"]["api-key"] == "<redacted>"
334
335 @pytest.mark.respx()
336 def test_azure_bearer_token_redacted(self, respx_mock: MockRouter, caplog: pytest.LogCaptureFixture) -> None:

Callers

nothing calls this directly

Calls 5

AzureOpenAIClass · 0.90
is_dictFunction · 0.90
postMethod · 0.45
createMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected