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

Method test_request_extra_headers

tests/test_client.py:1925–1945  ·  view source on GitHub ↗
(self, client: OpenAI)

Source from the content-addressed store, hash-verified

1923 assert data == {"foo": "bar", "baz": None}
1924
1925 def test_request_extra_headers(self, client: OpenAI) -> None:
1926 request = client._build_request(
1927 FinalRequestOptions(
1928 method="post",
1929 url="/foo",
1930 **make_request_options(extra_headers={"X-Foo": "Foo"}),
1931 ),
1932 )
1933 assert request.headers.get("X-Foo") == "Foo"
1934
1935 # `extra_headers` takes priority over `default_headers` when keys clash
1936 request = client.with_options(default_headers={"X-Bar": "true"})._build_request(
1937 FinalRequestOptions(
1938 method="post",
1939 url="/foo",
1940 **make_request_options(
1941 extra_headers={"X-Bar": "false"},
1942 ),
1943 ),
1944 )
1945 assert request.headers.get("X-Bar") == "false"
1946
1947 def test_request_extra_query(self, client: OpenAI) -> None:
1948 request = client._build_request(

Callers

nothing calls this directly

Calls 4

FinalRequestOptionsClass · 0.90
make_request_optionsFunction · 0.90
_build_requestMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected