openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.65.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/api_resources/beta/threads/test_messages.py

556lines · modeblame

5cfb125aStainless Bot2 years ago1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
baa9f07fRobert Craigie2 years ago2
3from __future__ import annotations
4
5import os
86379b44Stainless Bot2 years ago6from typing import Any, cast
baa9f07fRobert Craigie2 years ago7
8import pytest
9
10from openai import OpenAI, AsyncOpenAI
11from tests.utils import assert_matches_type
12from openai.pagination import SyncCursorPage, AsyncCursorPage
d2738d42Stainless Bot2 years ago13from openai.types.beta.threads import (
14Message,
15MessageDeleted,
16)
baa9f07fRobert Craigie2 years ago17
18base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
19
20
21class TestMessages:
98d779fbStainless Bot2 years ago22parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago23
24@parametrize
25def test_method_create(self, client: OpenAI) -> None:
26message = client.beta.threads.messages.create(
27"string",
79a0b401Stainless Bot2 years ago28content="string",
baa9f07fRobert Craigie2 years ago29role="user",
30)
5429f696Stainless Bot2 years ago31assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago32
33@parametrize
34def test_method_create_with_all_params(self, client: OpenAI) -> None:
35message = client.beta.threads.messages.create(
36"string",
79a0b401Stainless Bot2 years ago37content="string",
baa9f07fRobert Craigie2 years ago38role="user",
5b20698dStainless Bot2 years ago39attachments=[
40{
dd19d4f9Stainless Bot1 years ago41"file_id": "file_id",
42"tools": [{"type": "code_interpreter"}],
43}
5b20698dStainless Bot2 years ago44],
fdd52476stainless-app[bot]1 years ago45metadata={"foo": "string"},
baa9f07fRobert Craigie2 years ago46)
5429f696Stainless Bot2 years ago47assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago48
49@parametrize
50def test_raw_response_create(self, client: OpenAI) -> None:
51response = client.beta.threads.messages.with_raw_response.create(
52"string",
79a0b401Stainless Bot2 years ago53content="string",
baa9f07fRobert Craigie2 years ago54role="user",
55)
86379b44Stainless Bot2 years ago56
57assert response.is_closed is True
baa9f07fRobert Craigie2 years ago58assert response.http_request.headers.get("X-Stainless-Lang") == "python"
59message = response.parse()
5429f696Stainless Bot2 years ago60assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago61
86379b44Stainless Bot2 years ago62@parametrize
63def test_streaming_response_create(self, client: OpenAI) -> None:
64with client.beta.threads.messages.with_streaming_response.create(
65"string",
79a0b401Stainless Bot2 years ago66content="string",
86379b44Stainless Bot2 years ago67role="user",
68) as response:
69assert not response.is_closed
70assert response.http_request.headers.get("X-Stainless-Lang") == "python"
71
72message = response.parse()
5429f696Stainless Bot2 years ago73assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago74
75assert cast(Any, response.is_closed) is True
76
023a4e66Stainless Bot2 years ago77@parametrize
78def test_path_params_create(self, client: OpenAI) -> None:
79with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
80client.beta.threads.messages.with_raw_response.create(
81"",
79a0b401Stainless Bot2 years ago82content="string",
023a4e66Stainless Bot2 years ago83role="user",
84)
85
baa9f07fRobert Craigie2 years ago86@parametrize
87def test_method_retrieve(self, client: OpenAI) -> None:
88message = client.beta.threads.messages.retrieve(
89"string",
90thread_id="string",
91)
5429f696Stainless Bot2 years ago92assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago93
94@parametrize
95def test_raw_response_retrieve(self, client: OpenAI) -> None:
96response = client.beta.threads.messages.with_raw_response.retrieve(
97"string",
98thread_id="string",
99)
86379b44Stainless Bot2 years ago100
101assert response.is_closed is True
baa9f07fRobert Craigie2 years ago102assert response.http_request.headers.get("X-Stainless-Lang") == "python"
103message = response.parse()
5429f696Stainless Bot2 years ago104assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago105
86379b44Stainless Bot2 years ago106@parametrize
107def test_streaming_response_retrieve(self, client: OpenAI) -> None:
108with client.beta.threads.messages.with_streaming_response.retrieve(
109"string",
110thread_id="string",
111) as response:
112assert not response.is_closed
113assert response.http_request.headers.get("X-Stainless-Lang") == "python"
114
115message = response.parse()
5429f696Stainless Bot2 years ago116assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago117
118assert cast(Any, response.is_closed) is True
119
023a4e66Stainless Bot2 years ago120@parametrize
121def test_path_params_retrieve(self, client: OpenAI) -> None:
122with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
123client.beta.threads.messages.with_raw_response.retrieve(
124"string",
125thread_id="",
126)
127
128with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
129client.beta.threads.messages.with_raw_response.retrieve(
130"",
131thread_id="string",
132)
133
baa9f07fRobert Craigie2 years ago134@parametrize
135def test_method_update(self, client: OpenAI) -> None:
136message = client.beta.threads.messages.update(
137"string",
138thread_id="string",
139)
5429f696Stainless Bot2 years ago140assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago141
142@parametrize
143def test_method_update_with_all_params(self, client: OpenAI) -> None:
144message = client.beta.threads.messages.update(
fdd52476stainless-app[bot]1 years ago145message_id="message_id",
146thread_id="thread_id",
147metadata={"foo": "string"},
baa9f07fRobert Craigie2 years ago148)
5429f696Stainless Bot2 years ago149assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago150
151@parametrize
152def test_raw_response_update(self, client: OpenAI) -> None:
153response = client.beta.threads.messages.with_raw_response.update(
154"string",
155thread_id="string",
156)
86379b44Stainless Bot2 years ago157
158assert response.is_closed is True
baa9f07fRobert Craigie2 years ago159assert response.http_request.headers.get("X-Stainless-Lang") == "python"
160message = response.parse()
5429f696Stainless Bot2 years ago161assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago162
86379b44Stainless Bot2 years ago163@parametrize
164def test_streaming_response_update(self, client: OpenAI) -> None:
165with client.beta.threads.messages.with_streaming_response.update(
166"string",
167thread_id="string",
168) as response:
169assert not response.is_closed
170assert response.http_request.headers.get("X-Stainless-Lang") == "python"
171
172message = response.parse()
5429f696Stainless Bot2 years ago173assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago174
175assert cast(Any, response.is_closed) is True
176
023a4e66Stainless Bot2 years ago177@parametrize
178def test_path_params_update(self, client: OpenAI) -> None:
179with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
180client.beta.threads.messages.with_raw_response.update(
181"string",
182thread_id="",
183)
184
185with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
186client.beta.threads.messages.with_raw_response.update(
187"",
188thread_id="string",
189)
190
baa9f07fRobert Craigie2 years ago191@parametrize
192def test_method_list(self, client: OpenAI) -> None:
193message = client.beta.threads.messages.list(
194"string",
195)
5429f696Stainless Bot2 years ago196assert_matches_type(SyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago197
198@parametrize
199def test_method_list_with_all_params(self, client: OpenAI) -> None:
200message = client.beta.threads.messages.list(
201"string",
202after="string",
203before="string",
204limit=0,
205order="asc",
8efca3a3Stainless Bot2 years ago206run_id="string",
baa9f07fRobert Craigie2 years ago207)
5429f696Stainless Bot2 years ago208assert_matches_type(SyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago209
210@parametrize
211def test_raw_response_list(self, client: OpenAI) -> None:
212response = client.beta.threads.messages.with_raw_response.list(
213"string",
214)
86379b44Stainless Bot2 years ago215
216assert response.is_closed is True
baa9f07fRobert Craigie2 years ago217assert response.http_request.headers.get("X-Stainless-Lang") == "python"
218message = response.parse()
5429f696Stainless Bot2 years ago219assert_matches_type(SyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago220
86379b44Stainless Bot2 years ago221@parametrize
222def test_streaming_response_list(self, client: OpenAI) -> None:
223with client.beta.threads.messages.with_streaming_response.list(
224"string",
225) as response:
226assert not response.is_closed
227assert response.http_request.headers.get("X-Stainless-Lang") == "python"
228
229message = response.parse()
5429f696Stainless Bot2 years ago230assert_matches_type(SyncCursorPage[Message], message, path=["response"])
86379b44Stainless Bot2 years ago231
232assert cast(Any, response.is_closed) is True
233
023a4e66Stainless Bot2 years ago234@parametrize
235def test_path_params_list(self, client: OpenAI) -> None:
236with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
237client.beta.threads.messages.with_raw_response.list(
238"",
239)
240
d2738d42Stainless Bot2 years ago241@parametrize
242def test_method_delete(self, client: OpenAI) -> None:
243message = client.beta.threads.messages.delete(
244"string",
245thread_id="string",
246)
247assert_matches_type(MessageDeleted, message, path=["response"])
248
249@parametrize
250def test_raw_response_delete(self, client: OpenAI) -> None:
251response = client.beta.threads.messages.with_raw_response.delete(
252"string",
253thread_id="string",
254)
255
256assert response.is_closed is True
257assert response.http_request.headers.get("X-Stainless-Lang") == "python"
258message = response.parse()
259assert_matches_type(MessageDeleted, message, path=["response"])
260
261@parametrize
262def test_streaming_response_delete(self, client: OpenAI) -> None:
263with client.beta.threads.messages.with_streaming_response.delete(
264"string",
265thread_id="string",
266) as response:
267assert not response.is_closed
268assert response.http_request.headers.get("X-Stainless-Lang") == "python"
269
270message = response.parse()
271assert_matches_type(MessageDeleted, message, path=["response"])
272
273assert cast(Any, response.is_closed) is True
274
275@parametrize
276def test_path_params_delete(self, client: OpenAI) -> None:
277with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
278client.beta.threads.messages.with_raw_response.delete(
279"string",
280thread_id="",
281)
282
283with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
284client.beta.threads.messages.with_raw_response.delete(
285"",
286thread_id="string",
287)
288
baa9f07fRobert Craigie2 years ago289
290class TestAsyncMessages:
98d779fbStainless Bot2 years ago291parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago292
293@parametrize
98d779fbStainless Bot2 years ago294async def test_method_create(self, async_client: AsyncOpenAI) -> None:
295message = await async_client.beta.threads.messages.create(
baa9f07fRobert Craigie2 years ago296"string",
79a0b401Stainless Bot2 years ago297content="string",
baa9f07fRobert Craigie2 years ago298role="user",
299)
5429f696Stainless Bot2 years ago300assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago301
302@parametrize
98d779fbStainless Bot2 years ago303async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
304message = await async_client.beta.threads.messages.create(
baa9f07fRobert Craigie2 years ago305"string",
79a0b401Stainless Bot2 years ago306content="string",
baa9f07fRobert Craigie2 years ago307role="user",
5b20698dStainless Bot2 years ago308attachments=[
309{
dd19d4f9Stainless Bot1 years ago310"file_id": "file_id",
311"tools": [{"type": "code_interpreter"}],
312}
5b20698dStainless Bot2 years ago313],
fdd52476stainless-app[bot]1 years ago314metadata={"foo": "string"},
baa9f07fRobert Craigie2 years ago315)
5429f696Stainless Bot2 years ago316assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago317
318@parametrize
98d779fbStainless Bot2 years ago319async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
320response = await async_client.beta.threads.messages.with_raw_response.create(
baa9f07fRobert Craigie2 years ago321"string",
79a0b401Stainless Bot2 years ago322content="string",
baa9f07fRobert Craigie2 years ago323role="user",
324)
86379b44Stainless Bot2 years ago325
326assert response.is_closed is True
baa9f07fRobert Craigie2 years ago327assert response.http_request.headers.get("X-Stainless-Lang") == "python"
328message = response.parse()
5429f696Stainless Bot2 years ago329assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago330
86379b44Stainless Bot2 years ago331@parametrize
98d779fbStainless Bot2 years ago332async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
333async with async_client.beta.threads.messages.with_streaming_response.create(
86379b44Stainless Bot2 years ago334"string",
79a0b401Stainless Bot2 years ago335content="string",
86379b44Stainless Bot2 years ago336role="user",
337) as response:
338assert not response.is_closed
339assert response.http_request.headers.get("X-Stainless-Lang") == "python"
340
341message = await response.parse()
5429f696Stainless Bot2 years ago342assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago343
344assert cast(Any, response.is_closed) is True
345
023a4e66Stainless Bot2 years ago346@parametrize
98d779fbStainless Bot2 years ago347async def test_path_params_create(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago348with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago349await async_client.beta.threads.messages.with_raw_response.create(
023a4e66Stainless Bot2 years ago350"",
79a0b401Stainless Bot2 years ago351content="string",
023a4e66Stainless Bot2 years ago352role="user",
353)
354
baa9f07fRobert Craigie2 years ago355@parametrize
98d779fbStainless Bot2 years ago356async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
357message = await async_client.beta.threads.messages.retrieve(
baa9f07fRobert Craigie2 years ago358"string",
359thread_id="string",
360)
5429f696Stainless Bot2 years ago361assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago362
363@parametrize
98d779fbStainless Bot2 years ago364async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
365response = await async_client.beta.threads.messages.with_raw_response.retrieve(
baa9f07fRobert Craigie2 years ago366"string",
367thread_id="string",
368)
86379b44Stainless Bot2 years ago369
370assert response.is_closed is True
baa9f07fRobert Craigie2 years ago371assert response.http_request.headers.get("X-Stainless-Lang") == "python"
372message = response.parse()
5429f696Stainless Bot2 years ago373assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago374
86379b44Stainless Bot2 years ago375@parametrize
98d779fbStainless Bot2 years ago376async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
377async with async_client.beta.threads.messages.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago378"string",
379thread_id="string",
380) as response:
381assert not response.is_closed
382assert response.http_request.headers.get("X-Stainless-Lang") == "python"
383
384message = await response.parse()
5429f696Stainless Bot2 years ago385assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago386
387assert cast(Any, response.is_closed) is True
388
023a4e66Stainless Bot2 years ago389@parametrize
98d779fbStainless Bot2 years ago390async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago391with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago392await async_client.beta.threads.messages.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago393"string",
394thread_id="",
395)
396
397with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
98d779fbStainless Bot2 years ago398await async_client.beta.threads.messages.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago399"",
400thread_id="string",
401)
402
baa9f07fRobert Craigie2 years ago403@parametrize
98d779fbStainless Bot2 years ago404async def test_method_update(self, async_client: AsyncOpenAI) -> None:
405message = await async_client.beta.threads.messages.update(
baa9f07fRobert Craigie2 years ago406"string",
407thread_id="string",
408)
5429f696Stainless Bot2 years ago409assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago410
411@parametrize
98d779fbStainless Bot2 years ago412async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
413message = await async_client.beta.threads.messages.update(
fdd52476stainless-app[bot]1 years ago414message_id="message_id",
415thread_id="thread_id",
416metadata={"foo": "string"},
baa9f07fRobert Craigie2 years ago417)
5429f696Stainless Bot2 years ago418assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago419
420@parametrize
98d779fbStainless Bot2 years ago421async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
422response = await async_client.beta.threads.messages.with_raw_response.update(
baa9f07fRobert Craigie2 years ago423"string",
424thread_id="string",
425)
86379b44Stainless Bot2 years ago426
427assert response.is_closed is True
baa9f07fRobert Craigie2 years ago428assert response.http_request.headers.get("X-Stainless-Lang") == "python"
429message = response.parse()
5429f696Stainless Bot2 years ago430assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago431
86379b44Stainless Bot2 years ago432@parametrize
98d779fbStainless Bot2 years ago433async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
434async with async_client.beta.threads.messages.with_streaming_response.update(
86379b44Stainless Bot2 years ago435"string",
436thread_id="string",
437) as response:
438assert not response.is_closed
439assert response.http_request.headers.get("X-Stainless-Lang") == "python"
440
441message = await response.parse()
5429f696Stainless Bot2 years ago442assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago443
444assert cast(Any, response.is_closed) is True
445
023a4e66Stainless Bot2 years ago446@parametrize
98d779fbStainless Bot2 years ago447async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago448with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago449await async_client.beta.threads.messages.with_raw_response.update(
023a4e66Stainless Bot2 years ago450"string",
451thread_id="",
452)
453
454with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
98d779fbStainless Bot2 years ago455await async_client.beta.threads.messages.with_raw_response.update(
023a4e66Stainless Bot2 years ago456"",
457thread_id="string",
458)
459
baa9f07fRobert Craigie2 years ago460@parametrize
98d779fbStainless Bot2 years ago461async def test_method_list(self, async_client: AsyncOpenAI) -> None:
462message = await async_client.beta.threads.messages.list(
baa9f07fRobert Craigie2 years ago463"string",
464)
5429f696Stainless Bot2 years ago465assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago466
467@parametrize
98d779fbStainless Bot2 years ago468async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
469message = await async_client.beta.threads.messages.list(
baa9f07fRobert Craigie2 years ago470"string",
471after="string",
472before="string",
473limit=0,
474order="asc",
8efca3a3Stainless Bot2 years ago475run_id="string",
baa9f07fRobert Craigie2 years ago476)
5429f696Stainless Bot2 years ago477assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago478
479@parametrize
98d779fbStainless Bot2 years ago480async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
481response = await async_client.beta.threads.messages.with_raw_response.list(
baa9f07fRobert Craigie2 years ago482"string",
483)
86379b44Stainless Bot2 years ago484
485assert response.is_closed is True
baa9f07fRobert Craigie2 years ago486assert response.http_request.headers.get("X-Stainless-Lang") == "python"
487message = response.parse()
5429f696Stainless Bot2 years ago488assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
86379b44Stainless Bot2 years ago489
490@parametrize
98d779fbStainless Bot2 years ago491async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
492async with async_client.beta.threads.messages.with_streaming_response.list(
86379b44Stainless Bot2 years ago493"string",
494) as response:
495assert not response.is_closed
496assert response.http_request.headers.get("X-Stainless-Lang") == "python"
497
498message = await response.parse()
5429f696Stainless Bot2 years ago499assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
86379b44Stainless Bot2 years ago500
501assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago502
503@parametrize
98d779fbStainless Bot2 years ago504async def test_path_params_list(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago505with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago506await async_client.beta.threads.messages.with_raw_response.list(
023a4e66Stainless Bot2 years ago507"",
508)
d2738d42Stainless Bot2 years ago509
510@parametrize
511async def test_method_delete(self, async_client: AsyncOpenAI) -> None:
512message = await async_client.beta.threads.messages.delete(
513"string",
514thread_id="string",
515)
516assert_matches_type(MessageDeleted, message, path=["response"])
517
518@parametrize
519async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None:
520response = await async_client.beta.threads.messages.with_raw_response.delete(
521"string",
522thread_id="string",
523)
524
525assert response.is_closed is True
526assert response.http_request.headers.get("X-Stainless-Lang") == "python"
527message = response.parse()
528assert_matches_type(MessageDeleted, message, path=["response"])
529
530@parametrize
531async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None:
532async with async_client.beta.threads.messages.with_streaming_response.delete(
533"string",
534thread_id="string",
535) as response:
536assert not response.is_closed
537assert response.http_request.headers.get("X-Stainless-Lang") == "python"
538
539message = await response.parse()
540assert_matches_type(MessageDeleted, message, path=["response"])
541
542assert cast(Any, response.is_closed) is True
543
544@parametrize
545async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None:
546with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
547await async_client.beta.threads.messages.with_raw_response.delete(
548"string",
549thread_id="",
550)
551
552with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
553await async_client.beta.threads.messages.with_raw_response.delete(
554"",
555thread_id="string",
556)