(client: OpenAI)
| 183 | |
| 184 | @pytest.mark.asyncio |
| 185 | async 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 | |
| 206 | def test_response_parse_annotated_type(client: OpenAI) -> None: |
nothing calls this directly
no test coverage detected