MCPcopy
hub / github.com/openai/openai-python / test_response_basemodel_request_id

Function test_response_basemodel_request_id

tests/test_response.py:161–181  ·  tests/test_response.py::test_response_basemodel_request_id
(client: OpenAI)

Source from the content-addressed store, hash-verified

159
160
161def 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

Callers

nothing calls this directly

Calls 5

parseMethod · 0.95
APIResponseClass · 0.90
rich_print_strFunction · 0.85
to_dictMethod · 0.80
constructMethod · 0.45

Tested by

no test coverage detected