openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dfdcf571ced31f7859cd1871be39e2fb3af6bafa

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api_resources/beta/threads/test_messages.py

572lines · 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{
41"file_id": "string",
f73996b7Stainless Bot2 years ago42"tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago43},
44{
45"file_id": "string",
f73996b7Stainless Bot2 years ago46"tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago47},
48{
49"file_id": "string",
f73996b7Stainless Bot2 years ago50"tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago51},
52],
baa9f07fRobert Craigie2 years ago53metadata={},
54)
5429f696Stainless Bot2 years ago55assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago56
57@parametrize
58def test_raw_response_create(self, client: OpenAI) -> None:
59response = client.beta.threads.messages.with_raw_response.create(
60"string",
79a0b401Stainless Bot2 years ago61content="string",
baa9f07fRobert Craigie2 years ago62role="user",
63)
86379b44Stainless Bot2 years ago64
65assert response.is_closed is True
baa9f07fRobert Craigie2 years ago66assert response.http_request.headers.get("X-Stainless-Lang") == "python"
67message = response.parse()
5429f696Stainless Bot2 years ago68assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago69
86379b44Stainless Bot2 years ago70@parametrize
71def test_streaming_response_create(self, client: OpenAI) -> None:
72with client.beta.threads.messages.with_streaming_response.create(
73"string",
79a0b401Stainless Bot2 years ago74content="string",
86379b44Stainless Bot2 years ago75role="user",
76) as response:
77assert not response.is_closed
78assert response.http_request.headers.get("X-Stainless-Lang") == "python"
79
80message = response.parse()
5429f696Stainless Bot2 years ago81assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago82
83assert cast(Any, response.is_closed) is True
84
023a4e66Stainless Bot2 years ago85@parametrize
86def test_path_params_create(self, client: OpenAI) -> None:
87with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
88client.beta.threads.messages.with_raw_response.create(
89"",
79a0b401Stainless Bot2 years ago90content="string",
023a4e66Stainless Bot2 years ago91role="user",
92)
93
baa9f07fRobert Craigie2 years ago94@parametrize
95def test_method_retrieve(self, client: OpenAI) -> None:
96message = client.beta.threads.messages.retrieve(
97"string",
98thread_id="string",
99)
5429f696Stainless Bot2 years ago100assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago101
102@parametrize
103def test_raw_response_retrieve(self, client: OpenAI) -> None:
104response = client.beta.threads.messages.with_raw_response.retrieve(
105"string",
106thread_id="string",
107)
86379b44Stainless Bot2 years ago108
109assert response.is_closed is True
baa9f07fRobert Craigie2 years ago110assert response.http_request.headers.get("X-Stainless-Lang") == "python"
111message = response.parse()
5429f696Stainless Bot2 years ago112assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago113
86379b44Stainless Bot2 years ago114@parametrize
115def test_streaming_response_retrieve(self, client: OpenAI) -> None:
116with client.beta.threads.messages.with_streaming_response.retrieve(
117"string",
118thread_id="string",
119) as response:
120assert not response.is_closed
121assert response.http_request.headers.get("X-Stainless-Lang") == "python"
122
123message = response.parse()
5429f696Stainless Bot2 years ago124assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago125
126assert cast(Any, response.is_closed) is True
127
023a4e66Stainless Bot2 years ago128@parametrize
129def test_path_params_retrieve(self, client: OpenAI) -> None:
130with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
131client.beta.threads.messages.with_raw_response.retrieve(
132"string",
133thread_id="",
134)
135
136with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
137client.beta.threads.messages.with_raw_response.retrieve(
138"",
139thread_id="string",
140)
141
baa9f07fRobert Craigie2 years ago142@parametrize
143def test_method_update(self, client: OpenAI) -> None:
144message = client.beta.threads.messages.update(
145"string",
146thread_id="string",
147)
5429f696Stainless Bot2 years ago148assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago149
150@parametrize
151def test_method_update_with_all_params(self, client: OpenAI) -> None:
152message = client.beta.threads.messages.update(
153"string",
154thread_id="string",
155metadata={},
156)
5429f696Stainless Bot2 years ago157assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago158
159@parametrize
160def test_raw_response_update(self, client: OpenAI) -> None:
161response = client.beta.threads.messages.with_raw_response.update(
162"string",
163thread_id="string",
164)
86379b44Stainless Bot2 years ago165
166assert response.is_closed is True
baa9f07fRobert Craigie2 years ago167assert response.http_request.headers.get("X-Stainless-Lang") == "python"
168message = response.parse()
5429f696Stainless Bot2 years ago169assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago170
86379b44Stainless Bot2 years ago171@parametrize
172def test_streaming_response_update(self, client: OpenAI) -> None:
173with client.beta.threads.messages.with_streaming_response.update(
174"string",
175thread_id="string",
176) as response:
177assert not response.is_closed
178assert response.http_request.headers.get("X-Stainless-Lang") == "python"
179
180message = response.parse()
5429f696Stainless Bot2 years ago181assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago182
183assert cast(Any, response.is_closed) is True
184
023a4e66Stainless Bot2 years ago185@parametrize
186def test_path_params_update(self, client: OpenAI) -> None:
187with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
188client.beta.threads.messages.with_raw_response.update(
189"string",
190thread_id="",
191)
192
193with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
194client.beta.threads.messages.with_raw_response.update(
195"",
196thread_id="string",
197)
198
baa9f07fRobert Craigie2 years ago199@parametrize
200def test_method_list(self, client: OpenAI) -> None:
201message = client.beta.threads.messages.list(
202"string",
203)
5429f696Stainless Bot2 years ago204assert_matches_type(SyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago205
206@parametrize
207def test_method_list_with_all_params(self, client: OpenAI) -> None:
208message = client.beta.threads.messages.list(
209"string",
210after="string",
211before="string",
212limit=0,
213order="asc",
8efca3a3Stainless Bot2 years ago214run_id="string",
baa9f07fRobert Craigie2 years ago215)
5429f696Stainless Bot2 years ago216assert_matches_type(SyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago217
218@parametrize
219def test_raw_response_list(self, client: OpenAI) -> None:
220response = client.beta.threads.messages.with_raw_response.list(
221"string",
222)
86379b44Stainless Bot2 years ago223
224assert response.is_closed is True
baa9f07fRobert Craigie2 years ago225assert response.http_request.headers.get("X-Stainless-Lang") == "python"
226message = response.parse()
5429f696Stainless Bot2 years ago227assert_matches_type(SyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago228
86379b44Stainless Bot2 years ago229@parametrize
230def test_streaming_response_list(self, client: OpenAI) -> None:
231with client.beta.threads.messages.with_streaming_response.list(
232"string",
233) as response:
234assert not response.is_closed
235assert response.http_request.headers.get("X-Stainless-Lang") == "python"
236
237message = response.parse()
5429f696Stainless Bot2 years ago238assert_matches_type(SyncCursorPage[Message], message, path=["response"])
86379b44Stainless Bot2 years ago239
240assert cast(Any, response.is_closed) is True
241
023a4e66Stainless Bot2 years ago242@parametrize
243def test_path_params_list(self, client: OpenAI) -> None:
244with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
245client.beta.threads.messages.with_raw_response.list(
246"",
247)
248
d2738d42Stainless Bot2 years ago249@parametrize
250def test_method_delete(self, client: OpenAI) -> None:
251message = client.beta.threads.messages.delete(
252"string",
253thread_id="string",
254)
255assert_matches_type(MessageDeleted, message, path=["response"])
256
257@parametrize
258def test_raw_response_delete(self, client: OpenAI) -> None:
259response = client.beta.threads.messages.with_raw_response.delete(
260"string",
261thread_id="string",
262)
263
264assert response.is_closed is True
265assert response.http_request.headers.get("X-Stainless-Lang") == "python"
266message = response.parse()
267assert_matches_type(MessageDeleted, message, path=["response"])
268
269@parametrize
270def test_streaming_response_delete(self, client: OpenAI) -> None:
271with client.beta.threads.messages.with_streaming_response.delete(
272"string",
273thread_id="string",
274) as response:
275assert not response.is_closed
276assert response.http_request.headers.get("X-Stainless-Lang") == "python"
277
278message = response.parse()
279assert_matches_type(MessageDeleted, message, path=["response"])
280
281assert cast(Any, response.is_closed) is True
282
283@parametrize
284def test_path_params_delete(self, client: OpenAI) -> None:
285with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
286client.beta.threads.messages.with_raw_response.delete(
287"string",
288thread_id="",
289)
290
291with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
292client.beta.threads.messages.with_raw_response.delete(
293"",
294thread_id="string",
295)
296
baa9f07fRobert Craigie2 years ago297
298class TestAsyncMessages:
98d779fbStainless Bot2 years ago299parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago300
301@parametrize
98d779fbStainless Bot2 years ago302async def test_method_create(self, async_client: AsyncOpenAI) -> None:
303message = await async_client.beta.threads.messages.create(
baa9f07fRobert Craigie2 years ago304"string",
79a0b401Stainless Bot2 years ago305content="string",
baa9f07fRobert Craigie2 years ago306role="user",
307)
5429f696Stainless Bot2 years ago308assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago309
310@parametrize
98d779fbStainless Bot2 years ago311async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
312message = await async_client.beta.threads.messages.create(
baa9f07fRobert Craigie2 years ago313"string",
79a0b401Stainless Bot2 years ago314content="string",
baa9f07fRobert Craigie2 years ago315role="user",
5b20698dStainless Bot2 years ago316attachments=[
317{
318"file_id": "string",
f73996b7Stainless Bot2 years ago319"tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago320},
321{
322"file_id": "string",
f73996b7Stainless Bot2 years ago323"tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago324},
325{
326"file_id": "string",
f73996b7Stainless Bot2 years ago327"tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
5b20698dStainless Bot2 years ago328},
329],
baa9f07fRobert Craigie2 years ago330metadata={},
331)
5429f696Stainless Bot2 years ago332assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago333
334@parametrize
98d779fbStainless Bot2 years ago335async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
336response = await async_client.beta.threads.messages.with_raw_response.create(
baa9f07fRobert Craigie2 years ago337"string",
79a0b401Stainless Bot2 years ago338content="string",
baa9f07fRobert Craigie2 years ago339role="user",
340)
86379b44Stainless Bot2 years ago341
342assert response.is_closed is True
baa9f07fRobert Craigie2 years ago343assert response.http_request.headers.get("X-Stainless-Lang") == "python"
344message = response.parse()
5429f696Stainless Bot2 years ago345assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago346
86379b44Stainless Bot2 years ago347@parametrize
98d779fbStainless Bot2 years ago348async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
349async with async_client.beta.threads.messages.with_streaming_response.create(
86379b44Stainless Bot2 years ago350"string",
79a0b401Stainless Bot2 years ago351content="string",
86379b44Stainless Bot2 years ago352role="user",
353) as response:
354assert not response.is_closed
355assert response.http_request.headers.get("X-Stainless-Lang") == "python"
356
357message = await response.parse()
5429f696Stainless Bot2 years ago358assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago359
360assert cast(Any, response.is_closed) is True
361
023a4e66Stainless Bot2 years ago362@parametrize
98d779fbStainless Bot2 years ago363async def test_path_params_create(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago364with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago365await async_client.beta.threads.messages.with_raw_response.create(
023a4e66Stainless Bot2 years ago366"",
79a0b401Stainless Bot2 years ago367content="string",
023a4e66Stainless Bot2 years ago368role="user",
369)
370
baa9f07fRobert Craigie2 years ago371@parametrize
98d779fbStainless Bot2 years ago372async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
373message = await async_client.beta.threads.messages.retrieve(
baa9f07fRobert Craigie2 years ago374"string",
375thread_id="string",
376)
5429f696Stainless Bot2 years ago377assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago378
379@parametrize
98d779fbStainless Bot2 years ago380async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
381response = await async_client.beta.threads.messages.with_raw_response.retrieve(
baa9f07fRobert Craigie2 years ago382"string",
383thread_id="string",
384)
86379b44Stainless Bot2 years ago385
386assert response.is_closed is True
baa9f07fRobert Craigie2 years ago387assert response.http_request.headers.get("X-Stainless-Lang") == "python"
388message = response.parse()
5429f696Stainless Bot2 years ago389assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago390
86379b44Stainless Bot2 years ago391@parametrize
98d779fbStainless Bot2 years ago392async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
393async with async_client.beta.threads.messages.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago394"string",
395thread_id="string",
396) as response:
397assert not response.is_closed
398assert response.http_request.headers.get("X-Stainless-Lang") == "python"
399
400message = await response.parse()
5429f696Stainless Bot2 years ago401assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago402
403assert cast(Any, response.is_closed) is True
404
023a4e66Stainless Bot2 years ago405@parametrize
98d779fbStainless Bot2 years ago406async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago407with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago408await async_client.beta.threads.messages.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago409"string",
410thread_id="",
411)
412
413with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
98d779fbStainless Bot2 years ago414await async_client.beta.threads.messages.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago415"",
416thread_id="string",
417)
418
baa9f07fRobert Craigie2 years ago419@parametrize
98d779fbStainless Bot2 years ago420async def test_method_update(self, async_client: AsyncOpenAI) -> None:
421message = await async_client.beta.threads.messages.update(
baa9f07fRobert Craigie2 years ago422"string",
423thread_id="string",
424)
5429f696Stainless Bot2 years ago425assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago426
427@parametrize
98d779fbStainless Bot2 years ago428async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
429message = await async_client.beta.threads.messages.update(
baa9f07fRobert Craigie2 years ago430"string",
431thread_id="string",
432metadata={},
433)
5429f696Stainless Bot2 years ago434assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago435
436@parametrize
98d779fbStainless Bot2 years ago437async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
438response = await async_client.beta.threads.messages.with_raw_response.update(
baa9f07fRobert Craigie2 years ago439"string",
440thread_id="string",
441)
86379b44Stainless Bot2 years ago442
443assert response.is_closed is True
baa9f07fRobert Craigie2 years ago444assert response.http_request.headers.get("X-Stainless-Lang") == "python"
445message = response.parse()
5429f696Stainless Bot2 years ago446assert_matches_type(Message, message, path=["response"])
baa9f07fRobert Craigie2 years ago447
86379b44Stainless Bot2 years ago448@parametrize
98d779fbStainless Bot2 years ago449async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
450async with async_client.beta.threads.messages.with_streaming_response.update(
86379b44Stainless Bot2 years ago451"string",
452thread_id="string",
453) as response:
454assert not response.is_closed
455assert response.http_request.headers.get("X-Stainless-Lang") == "python"
456
457message = await response.parse()
5429f696Stainless Bot2 years ago458assert_matches_type(Message, message, path=["response"])
86379b44Stainless Bot2 years ago459
460assert cast(Any, response.is_closed) is True
461
023a4e66Stainless Bot2 years ago462@parametrize
98d779fbStainless Bot2 years ago463async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago464with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago465await async_client.beta.threads.messages.with_raw_response.update(
023a4e66Stainless Bot2 years ago466"string",
467thread_id="",
468)
469
470with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
98d779fbStainless Bot2 years ago471await async_client.beta.threads.messages.with_raw_response.update(
023a4e66Stainless Bot2 years ago472"",
473thread_id="string",
474)
475
baa9f07fRobert Craigie2 years ago476@parametrize
98d779fbStainless Bot2 years ago477async def test_method_list(self, async_client: AsyncOpenAI) -> None:
478message = await async_client.beta.threads.messages.list(
baa9f07fRobert Craigie2 years ago479"string",
480)
5429f696Stainless Bot2 years ago481assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago482
483@parametrize
98d779fbStainless Bot2 years ago484async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
485message = await async_client.beta.threads.messages.list(
baa9f07fRobert Craigie2 years ago486"string",
487after="string",
488before="string",
489limit=0,
490order="asc",
8efca3a3Stainless Bot2 years ago491run_id="string",
baa9f07fRobert Craigie2 years ago492)
5429f696Stainless Bot2 years ago493assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
baa9f07fRobert Craigie2 years ago494
495@parametrize
98d779fbStainless Bot2 years ago496async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
497response = await async_client.beta.threads.messages.with_raw_response.list(
baa9f07fRobert Craigie2 years ago498"string",
499)
86379b44Stainless Bot2 years ago500
501assert response.is_closed is True
baa9f07fRobert Craigie2 years ago502assert response.http_request.headers.get("X-Stainless-Lang") == "python"
503message = response.parse()
5429f696Stainless Bot2 years ago504assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
86379b44Stainless Bot2 years ago505
506@parametrize
98d779fbStainless Bot2 years ago507async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
508async with async_client.beta.threads.messages.with_streaming_response.list(
86379b44Stainless Bot2 years ago509"string",
510) as response:
511assert not response.is_closed
512assert response.http_request.headers.get("X-Stainless-Lang") == "python"
513
514message = await response.parse()
5429f696Stainless Bot2 years ago515assert_matches_type(AsyncCursorPage[Message], message, path=["response"])
86379b44Stainless Bot2 years ago516
517assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago518
519@parametrize
98d779fbStainless Bot2 years ago520async def test_path_params_list(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago521with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago522await async_client.beta.threads.messages.with_raw_response.list(
023a4e66Stainless Bot2 years ago523"",
524)
d2738d42Stainless Bot2 years ago525
526@parametrize
527async def test_method_delete(self, async_client: AsyncOpenAI) -> None:
528message = await async_client.beta.threads.messages.delete(
529"string",
530thread_id="string",
531)
532assert_matches_type(MessageDeleted, message, path=["response"])
533
534@parametrize
535async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None:
536response = await async_client.beta.threads.messages.with_raw_response.delete(
537"string",
538thread_id="string",
539)
540
541assert response.is_closed is True
542assert response.http_request.headers.get("X-Stainless-Lang") == "python"
543message = response.parse()
544assert_matches_type(MessageDeleted, message, path=["response"])
545
546@parametrize
547async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None:
548async with async_client.beta.threads.messages.with_streaming_response.delete(
549"string",
550thread_id="string",
551) as response:
552assert not response.is_closed
553assert response.http_request.headers.get("X-Stainless-Lang") == "python"
554
555message = await response.parse()
556assert_matches_type(MessageDeleted, message, path=["response"])
557
558assert cast(Any, response.is_closed) is True
559
560@parametrize
561async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None:
562with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
563await async_client.beta.threads.messages.with_raw_response.delete(
564"string",
565thread_id="",
566)
567
568with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"):
569await async_client.beta.threads.messages.with_raw_response.delete(
570"",
571thread_id="string",
572)