(client: OpenAI)
| 159 | |
| 160 | |
| 161 | def test_response_basemodel_request_id(client: OpenAI) -> None: |
| 162 | response = APIResponse( |
| 163 | raw=httpx.Response( |
| 164 | 200, |
| 165 | headers={"x-request-id": "my-req-id"}, |
| 166 | content=json.dumps({"foo": "hello!", "bar": 2}), |
| 167 | ), |
| 168 | client=client, |
| 169 | stream=False, |
| 170 | stream_cls=None, |
| 171 | cast_to=str, |
| 172 | options=FinalRequestOptions.construct(method="get", url="/foo"), |
| 173 | ) |
| 174 | |
| 175 | obj = response.parse(to=CustomModel) |
| 176 | assert obj._request_id == "my-req-id" |
| 177 | assert obj.foo == "hello!" |
| 178 | assert obj.bar == 2 |
| 179 | assert obj.to_dict() == {"foo": "hello!", "bar": 2} |
| 180 | assert "_request_id" not in rich_print_str(obj) |
| 181 | assert "__exclude_fields__" not in rich_print_str(obj) |
| 182 | |
| 183 | |
| 184 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected