(client: OpenAI)
| 94 | |
| 95 | |
| 96 | def test_response_basemodel_request_id(client: OpenAI) -> None: |
| 97 | response = LegacyAPIResponse( |
| 98 | raw=httpx.Response( |
| 99 | 200, |
| 100 | headers={"x-request-id": "my-req-id"}, |
| 101 | content=json.dumps({"foo": "hello!", "bar": 2}), |
| 102 | ), |
| 103 | client=client, |
| 104 | stream=False, |
| 105 | stream_cls=None, |
| 106 | cast_to=str, |
| 107 | options=FinalRequestOptions.construct(method="get", url="/foo"), |
| 108 | ) |
| 109 | |
| 110 | obj = response.parse(to=CustomModel) |
| 111 | assert obj._request_id == "my-req-id" |
| 112 | assert obj.foo == "hello!" |
| 113 | assert obj.bar == 2 |
| 114 | assert obj.to_dict() == {"foo": "hello!", "bar": 2} |
| 115 | assert "_request_id" not in rich_print_str(obj) |
| 116 | assert "__exclude_fields__" not in rich_print_str(obj) |
| 117 | |
| 118 | |
| 119 | def test_response_parse_annotated_type(client: OpenAI) -> None: |
nothing calls this directly
no test coverage detected