MCPcopy Index your code
hub / github.com/openai/openai-python / test_request_extra_query

Method test_request_extra_query

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

Source from the content-addressed store, hash-verified

1945 assert request.headers.get("X-Bar") == "false"
1946
1947 def test_request_extra_query(self, client: OpenAI) -> None:
1948 request = client._build_request(
1949 FinalRequestOptions(
1950 method="post",
1951 url="/foo",
1952 **make_request_options(
1953 extra_query={"my_query_param": "Foo"},
1954 ),
1955 ),
1956 )
1957 params = dict(request.url.params)
1958 assert params == {"my_query_param": "Foo"}
1959
1960 # if both `query` and `extra_query` are given, they are merged
1961 request = client._build_request(
1962 FinalRequestOptions(
1963 method="post",
1964 url="/foo",
1965 **make_request_options(
1966 query={"bar": "1"},
1967 extra_query={"foo": "2"},
1968 ),
1969 ),
1970 )
1971 params = dict(request.url.params)
1972 assert params == {"bar": "1", "foo": "2"}
1973
1974 # `extra_query` takes priority over `query` when keys clash
1975 request = client._build_request(
1976 FinalRequestOptions(
1977 method="post",
1978 url="/foo",
1979 **make_request_options(
1980 query={"foo": "1"},
1981 extra_query={"foo": "2"},
1982 ),
1983 ),
1984 )
1985 params = dict(request.url.params)
1986 assert params == {"foo": "2"}
1987
1988 def test_multipart_repeating_array(self, async_client: AsyncOpenAI) -> None:
1989 request = async_client._build_request(

Callers

nothing calls this directly

Calls 3

FinalRequestOptionsClass · 0.90
make_request_optionsFunction · 0.90
_build_requestMethod · 0.45

Tested by

no test coverage detected