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

Method test_default_headers_option

tests/test_client.py:1684–1711  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1682 )
1683
1684 async def test_default_headers_option(self) -> None:
1685 test_client = AsyncOpenAI(
1686 base_url=base_url,
1687 api_key=api_key,
1688 admin_api_key=admin_api_key,
1689 _strict_response_validation=True,
1690 default_headers={"X-Foo": "bar"},
1691 )
1692 request = test_client._build_request(FinalRequestOptions(method="get", url="/foo"))
1693 assert request.headers.get("x-foo") == "bar"
1694 assert request.headers.get("x-stainless-lang") == "python"
1695
1696 test_client2 = AsyncOpenAI(
1697 base_url=base_url,
1698 api_key=api_key,
1699 admin_api_key=admin_api_key,
1700 _strict_response_validation=True,
1701 default_headers={
1702 "X-Foo": "stainless",
1703 "X-Stainless-Lang": "my-overriding-header",
1704 },
1705 )
1706 request = test_client2._build_request(FinalRequestOptions(method="get", url="/foo"))
1707 assert request.headers.get("x-foo") == "stainless"
1708 assert request.headers.get("x-stainless-lang") == "my-overriding-header"
1709
1710 await test_client.close()
1711 await test_client2.close()
1712
1713 async def test_validate_headers(self) -> None:
1714 client = AsyncOpenAI(

Callers

nothing calls this directly

Calls 5

AsyncOpenAIClass · 0.90
FinalRequestOptionsClass · 0.90
_build_requestMethod · 0.45
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected