(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={class="st">"x-request-id": class="st">"my-req-id"}, |
| 166 | content=json.dumps({class="st">"foo": class="st">"hello!", class="st">"bar": 2}), |
| 167 | ), |
| 168 | client=client, |
| 169 | stream=False, |
| 170 | stream_cls=None, |
| 171 | cast_to=str, |
| 172 | options=FinalRequestOptions.construct(method=class="st">"get", url=class="st">"/foo"), |
| 173 | ) |
| 174 | |
| 175 | obj = response.parse(to=CustomModel) |
| 176 | assert obj._request_id == class="st">"my-req-id" |
| 177 | assert obj.foo == class="st">"hello!" |
| 178 | assert obj.bar == 2 |
| 179 | assert obj.to_dict() == {class="st">"foo": class="st">"hello!", class="st">"bar": 2} |
| 180 | assert class="st">"_request_id" not in rich_print_str(obj) |
| 181 | assert class="st">"__exclude_fields__" not in rich_print_str(obj) |
| 182 | |
| 183 | |
| 184 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected