MCPcopy Create free account
hub / github.com/openai/openai-python / test_response_basemodel_request_id

Function test_response_basemodel_request_id

tests/test_legacy_response.py:96–116  ·  view source on GitHub ↗
(client: OpenAI)

Source from the content-addressed store, hash-verified

94
95
96def 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
119def test_response_parse_annotated_type(client: OpenAI) -> None:

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected