MCPcopy Create free account
hub / github.com/openai/openai-python / test_async_response_basemodel_request_id

Function test_async_response_basemodel_request_id

tests/test_response.py:185–203  ·  view source on GitHub ↗
(client: OpenAI)

Source from the content-addressed store, hash-verified

183
184@pytest.mark.asyncio
185async def test_async_response_basemodel_request_id(client: OpenAI) -> None:
186 response = AsyncAPIResponse(
187 raw=httpx.Response(
188 200,
189 headers={"x-request-id": "my-req-id"},
190 content=json.dumps({"foo": "hello!", "bar": 2}),
191 ),
192 client=client,
193 stream=False,
194 stream_cls=None,
195 cast_to=str,
196 options=FinalRequestOptions.construct(method="get", url="/foo"),
197 )
198
199 obj = await response.parse(to=CustomModel)
200 assert obj._request_id == "my-req-id"
201 assert obj.foo == "hello!"
202 assert obj.bar == 2
203 assert obj.to_dict() == {"foo": "hello!", "bar": 2}
204
205
206def test_response_parse_annotated_type(client: OpenAI) -> None:

Callers

nothing calls this directly

Calls 4

parseMethod · 0.95
AsyncAPIResponseClass · 0.90
to_dictMethod · 0.80
constructMethod · 0.45

Tested by

no test coverage detected