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

Method test_request_extra_headers

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

Source from the content-addressed store, hash-verified

672 assert data == {"foo": "bar", "baz": None}
673
674 def test_request_extra_headers(self, client: OpenAI) -> None:
675 request = client._build_request(
676 FinalRequestOptions(
677 method="post",
678 url="/foo",
679 **make_request_options(extra_headers={"X-Foo": "Foo"}),
680 ),
681 )
682 assert request.headers.get("X-Foo") == "Foo"
683
684 # `extra_headers` takes priority over `default_headers` when keys clash
685 request = client.with_options(default_headers={"X-Bar": "true"})._build_request(
686 FinalRequestOptions(
687 method="post",
688 url="/foo",
689 **make_request_options(
690 extra_headers={"X-Bar": "false"},
691 ),
692 ),
693 )
694 assert request.headers.get("X-Bar") == "false"
695
696 def test_request_extra_query(self, client: OpenAI) -> None:
697 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