openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
custom-code-from-generated-20260521

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api_resources/beta/test_assistants.py

548lines · 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
4a0f0fa0Stainless Bot2 years ago13from openai.types.beta import (
14Assistant,
15AssistantDeleted,
16)
baa9f07fRobert Craigie2 years ago17
c4f76b2estainless-app[bot]5 months ago18# pyright: reportDeprecated=false
19
baa9f07fRobert Craigie2 years ago20base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
21
22
23class TestAssistants:
98d779fbStainless Bot2 years ago24parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago25
26@parametrize
27def test_method_create(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago28with pytest.warns(DeprecationWarning):
29assistant = client.beta.assistants.create(
30model="gpt-4o",
31)
32
baa9f07fRobert Craigie2 years ago33assert_matches_type(Assistant, assistant, path=["response"])
34
35@parametrize
36def test_method_create_with_all_params(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago37with pytest.warns(DeprecationWarning):
38assistant = client.beta.assistants.create(
39model="gpt-4o",
40description="description",
41instructions="instructions",
42metadata={"foo": "string"},
43name="name",
44reasoning_effort="none",
45response_format="auto",
46temperature=1,
47tool_resources={
48"code_interpreter": {"file_ids": ["string"]},
49"file_search": {
50"vector_store_ids": ["string"],
51"vector_stores": [
52{
53"chunking_strategy": {"type": "auto"},
54"file_ids": ["string"],
55"metadata": {"foo": "string"},
56}
57],
58},
5b20698dStainless Bot2 years ago59},
c4f76b2estainless-app[bot]5 months ago60tools=[{"type": "code_interpreter"}],
61top_p=1,
62)
63
baa9f07fRobert Craigie2 years ago64assert_matches_type(Assistant, assistant, path=["response"])
65
66@parametrize
67def test_raw_response_create(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago68with pytest.warns(DeprecationWarning):
69response = client.beta.assistants.with_raw_response.create(
70model="gpt-4o",
71)
86379b44Stainless Bot2 years ago72
73assert response.is_closed is True
baa9f07fRobert Craigie2 years ago74assert response.http_request.headers.get("X-Stainless-Lang") == "python"
75assistant = response.parse()
76assert_matches_type(Assistant, assistant, path=["response"])
77
86379b44Stainless Bot2 years ago78@parametrize
79def test_streaming_response_create(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago80with pytest.warns(DeprecationWarning):
81with client.beta.assistants.with_streaming_response.create(
82model="gpt-4o",
83) as response:
84assert not response.is_closed
85assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago86
c4f76b2estainless-app[bot]5 months ago87assistant = response.parse()
88assert_matches_type(Assistant, assistant, path=["response"])
86379b44Stainless Bot2 years ago89
90assert cast(Any, response.is_closed) is True
91
baa9f07fRobert Craigie2 years ago92@parametrize
93def test_method_retrieve(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago94with pytest.warns(DeprecationWarning):
95assistant = client.beta.assistants.retrieve(
96"assistant_id",
97)
98
baa9f07fRobert Craigie2 years ago99assert_matches_type(Assistant, assistant, path=["response"])
100
101@parametrize
102def test_raw_response_retrieve(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago103with pytest.warns(DeprecationWarning):
104response = client.beta.assistants.with_raw_response.retrieve(
105"assistant_id",
106)
86379b44Stainless Bot2 years ago107
108assert response.is_closed is True
baa9f07fRobert Craigie2 years ago109assert response.http_request.headers.get("X-Stainless-Lang") == "python"
110assistant = response.parse()
111assert_matches_type(Assistant, assistant, path=["response"])
112
86379b44Stainless Bot2 years ago113@parametrize
114def test_streaming_response_retrieve(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago115with pytest.warns(DeprecationWarning):
116with client.beta.assistants.with_streaming_response.retrieve(
117"assistant_id",
118) as response:
119assert not response.is_closed
120assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago121
c4f76b2estainless-app[bot]5 months ago122assistant = response.parse()
123assert_matches_type(Assistant, assistant, path=["response"])
86379b44Stainless Bot2 years ago124
125assert cast(Any, response.is_closed) is True
126
023a4e66Stainless Bot2 years ago127@parametrize
128def test_path_params_retrieve(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago129with pytest.warns(DeprecationWarning):
130with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
131client.beta.assistants.with_raw_response.retrieve(
132"",
133)
023a4e66Stainless Bot2 years ago134
baa9f07fRobert Craigie2 years ago135@parametrize
136def test_method_update(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago137with pytest.warns(DeprecationWarning):
138assistant = client.beta.assistants.update(
139assistant_id="assistant_id",
140)
141
baa9f07fRobert Craigie2 years ago142assert_matches_type(Assistant, assistant, path=["response"])
143
144@parametrize
145def test_method_update_with_all_params(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago146with pytest.warns(DeprecationWarning):
147assistant = client.beta.assistants.update(
148assistant_id="assistant_id",
149description="description",
150instructions="instructions",
151metadata={"foo": "string"},
e5b65b1fstainless-app[bot]3 months ago152model="gpt-5",
c4f76b2estainless-app[bot]5 months ago153name="name",
154reasoning_effort="none",
155response_format="auto",
156temperature=1,
157tool_resources={
158"code_interpreter": {"file_ids": ["string"]},
159"file_search": {"vector_store_ids": ["string"]},
160},
161tools=[{"type": "code_interpreter"}],
162top_p=1,
163)
164
baa9f07fRobert Craigie2 years ago165assert_matches_type(Assistant, assistant, path=["response"])
166
167@parametrize
168def test_raw_response_update(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago169with pytest.warns(DeprecationWarning):
170response = client.beta.assistants.with_raw_response.update(
171assistant_id="assistant_id",
172)
86379b44Stainless Bot2 years ago173
174assert response.is_closed is True
baa9f07fRobert Craigie2 years ago175assert response.http_request.headers.get("X-Stainless-Lang") == "python"
176assistant = response.parse()
177assert_matches_type(Assistant, assistant, path=["response"])
178
86379b44Stainless Bot2 years ago179@parametrize
180def test_streaming_response_update(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago181with pytest.warns(DeprecationWarning):
182with client.beta.assistants.with_streaming_response.update(
183assistant_id="assistant_id",
184) as response:
185assert not response.is_closed
186assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago187
c4f76b2estainless-app[bot]5 months ago188assistant = response.parse()
189assert_matches_type(Assistant, assistant, path=["response"])
86379b44Stainless Bot2 years ago190
191assert cast(Any, response.is_closed) is True
192
023a4e66Stainless Bot2 years ago193@parametrize
194def test_path_params_update(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago195with pytest.warns(DeprecationWarning):
196with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
197client.beta.assistants.with_raw_response.update(
198assistant_id="",
199)
023a4e66Stainless Bot2 years ago200
baa9f07fRobert Craigie2 years ago201@parametrize
202def test_method_list(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago203with pytest.warns(DeprecationWarning):
204assistant = client.beta.assistants.list()
205
baa9f07fRobert Craigie2 years ago206assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"])
207
208@parametrize
209def test_method_list_with_all_params(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago210with pytest.warns(DeprecationWarning):
211assistant = client.beta.assistants.list(
212after="after",
213before="before",
214limit=0,
215order="asc",
216)
217
baa9f07fRobert Craigie2 years ago218assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"])
219
220@parametrize
221def test_raw_response_list(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago222with pytest.warns(DeprecationWarning):
223response = client.beta.assistants.with_raw_response.list()
86379b44Stainless Bot2 years ago224
225assert response.is_closed is True
baa9f07fRobert Craigie2 years ago226assert response.http_request.headers.get("X-Stainless-Lang") == "python"
227assistant = response.parse()
228assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"])
229
86379b44Stainless Bot2 years ago230@parametrize
231def test_streaming_response_list(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago232with pytest.warns(DeprecationWarning):
233with client.beta.assistants.with_streaming_response.list() as response:
234assert not response.is_closed
235assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago236
c4f76b2estainless-app[bot]5 months ago237assistant = response.parse()
238assert_matches_type(SyncCursorPage[Assistant], assistant, path=["response"])
86379b44Stainless Bot2 years ago239
240assert cast(Any, response.is_closed) is True
241
baa9f07fRobert Craigie2 years ago242@parametrize
243def test_method_delete(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago244with pytest.warns(DeprecationWarning):
245assistant = client.beta.assistants.delete(
246"assistant_id",
247)
248
f5ef2b3aStainless Bot2 years ago249assert_matches_type(AssistantDeleted, assistant, path=["response"])
baa9f07fRobert Craigie2 years ago250
251@parametrize
252def test_raw_response_delete(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago253with pytest.warns(DeprecationWarning):
254response = client.beta.assistants.with_raw_response.delete(
255"assistant_id",
256)
86379b44Stainless Bot2 years ago257
258assert response.is_closed is True
baa9f07fRobert Craigie2 years ago259assert response.http_request.headers.get("X-Stainless-Lang") == "python"
260assistant = response.parse()
f5ef2b3aStainless Bot2 years ago261assert_matches_type(AssistantDeleted, assistant, path=["response"])
baa9f07fRobert Craigie2 years ago262
86379b44Stainless Bot2 years ago263@parametrize
264def test_streaming_response_delete(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago265with pytest.warns(DeprecationWarning):
266with client.beta.assistants.with_streaming_response.delete(
267"assistant_id",
268) as response:
269assert not response.is_closed
270assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago271
c4f76b2estainless-app[bot]5 months ago272assistant = response.parse()
273assert_matches_type(AssistantDeleted, assistant, path=["response"])
86379b44Stainless Bot2 years ago274
275assert cast(Any, response.is_closed) is True
276
023a4e66Stainless Bot2 years ago277@parametrize
278def test_path_params_delete(self, client: OpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago279with pytest.warns(DeprecationWarning):
280with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
281client.beta.assistants.with_raw_response.delete(
282"",
283)
023a4e66Stainless Bot2 years ago284
baa9f07fRobert Craigie2 years ago285
286class TestAsyncAssistants:
d7700afdstainless-app[bot]1 years ago287parametrize = pytest.mark.parametrize(
288"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
289)
baa9f07fRobert Craigie2 years ago290
291@parametrize
98d779fbStainless Bot2 years ago292async def test_method_create(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago293with pytest.warns(DeprecationWarning):
294assistant = await async_client.beta.assistants.create(
295model="gpt-4o",
296)
297
baa9f07fRobert Craigie2 years ago298assert_matches_type(Assistant, assistant, path=["response"])
299
300@parametrize
98d779fbStainless Bot2 years ago301async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago302with pytest.warns(DeprecationWarning):
303assistant = await async_client.beta.assistants.create(
304model="gpt-4o",
305description="description",
306instructions="instructions",
307metadata={"foo": "string"},
308name="name",
309reasoning_effort="none",
310response_format="auto",
311temperature=1,
312tool_resources={
313"code_interpreter": {"file_ids": ["string"]},
314"file_search": {
315"vector_store_ids": ["string"],
316"vector_stores": [
317{
318"chunking_strategy": {"type": "auto"},
319"file_ids": ["string"],
320"metadata": {"foo": "string"},
321}
322],
323},
5b20698dStainless Bot2 years ago324},
c4f76b2estainless-app[bot]5 months ago325tools=[{"type": "code_interpreter"}],
326top_p=1,
327)
328
baa9f07fRobert Craigie2 years ago329assert_matches_type(Assistant, assistant, path=["response"])
330
331@parametrize
98d779fbStainless Bot2 years ago332async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago333with pytest.warns(DeprecationWarning):
334response = await async_client.beta.assistants.with_raw_response.create(
335model="gpt-4o",
336)
86379b44Stainless Bot2 years ago337
338assert response.is_closed is True
baa9f07fRobert Craigie2 years ago339assert response.http_request.headers.get("X-Stainless-Lang") == "python"
340assistant = response.parse()
341assert_matches_type(Assistant, assistant, path=["response"])
342
86379b44Stainless Bot2 years ago343@parametrize
98d779fbStainless Bot2 years ago344async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago345with pytest.warns(DeprecationWarning):
346async with async_client.beta.assistants.with_streaming_response.create(
347model="gpt-4o",
348) as response:
349assert not response.is_closed
350assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago351
c4f76b2estainless-app[bot]5 months ago352assistant = await response.parse()
353assert_matches_type(Assistant, assistant, path=["response"])
86379b44Stainless Bot2 years ago354
355assert cast(Any, response.is_closed) is True
356
baa9f07fRobert Craigie2 years ago357@parametrize
98d779fbStainless Bot2 years ago358async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago359with pytest.warns(DeprecationWarning):
360assistant = await async_client.beta.assistants.retrieve(
361"assistant_id",
362)
363
baa9f07fRobert Craigie2 years ago364assert_matches_type(Assistant, assistant, path=["response"])
365
366@parametrize
98d779fbStainless Bot2 years ago367async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago368with pytest.warns(DeprecationWarning):
369response = await async_client.beta.assistants.with_raw_response.retrieve(
370"assistant_id",
371)
86379b44Stainless Bot2 years ago372
373assert response.is_closed is True
baa9f07fRobert Craigie2 years ago374assert response.http_request.headers.get("X-Stainless-Lang") == "python"
375assistant = response.parse()
376assert_matches_type(Assistant, assistant, path=["response"])
377
86379b44Stainless Bot2 years ago378@parametrize
98d779fbStainless Bot2 years ago379async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago380with pytest.warns(DeprecationWarning):
381async with async_client.beta.assistants.with_streaming_response.retrieve(
382"assistant_id",
383) as response:
384assert not response.is_closed
385assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago386
c4f76b2estainless-app[bot]5 months ago387assistant = await response.parse()
388assert_matches_type(Assistant, assistant, path=["response"])
86379b44Stainless Bot2 years ago389
390assert cast(Any, response.is_closed) is True
391
023a4e66Stainless Bot2 years ago392@parametrize
98d779fbStainless Bot2 years ago393async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago394with pytest.warns(DeprecationWarning):
395with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
396await async_client.beta.assistants.with_raw_response.retrieve(
397"",
398)
023a4e66Stainless Bot2 years ago399
baa9f07fRobert Craigie2 years ago400@parametrize
98d779fbStainless Bot2 years ago401async def test_method_update(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago402with pytest.warns(DeprecationWarning):
403assistant = await async_client.beta.assistants.update(
404assistant_id="assistant_id",
405)
406
baa9f07fRobert Craigie2 years ago407assert_matches_type(Assistant, assistant, path=["response"])
408
409@parametrize
98d779fbStainless Bot2 years ago410async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago411with pytest.warns(DeprecationWarning):
412assistant = await async_client.beta.assistants.update(
413assistant_id="assistant_id",
414description="description",
415instructions="instructions",
416metadata={"foo": "string"},
e5b65b1fstainless-app[bot]3 months ago417model="gpt-5",
c4f76b2estainless-app[bot]5 months ago418name="name",
419reasoning_effort="none",
420response_format="auto",
421temperature=1,
422tool_resources={
423"code_interpreter": {"file_ids": ["string"]},
424"file_search": {"vector_store_ids": ["string"]},
425},
426tools=[{"type": "code_interpreter"}],
427top_p=1,
428)
429
baa9f07fRobert Craigie2 years ago430assert_matches_type(Assistant, assistant, path=["response"])
431
432@parametrize
98d779fbStainless Bot2 years ago433async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago434with pytest.warns(DeprecationWarning):
435response = await async_client.beta.assistants.with_raw_response.update(
436assistant_id="assistant_id",
437)
86379b44Stainless Bot2 years ago438
439assert response.is_closed is True
baa9f07fRobert Craigie2 years ago440assert response.http_request.headers.get("X-Stainless-Lang") == "python"
441assistant = response.parse()
442assert_matches_type(Assistant, assistant, path=["response"])
443
86379b44Stainless Bot2 years ago444@parametrize
98d779fbStainless Bot2 years ago445async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago446with pytest.warns(DeprecationWarning):
447async with async_client.beta.assistants.with_streaming_response.update(
448assistant_id="assistant_id",
449) as response:
450assert not response.is_closed
451assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago452
c4f76b2estainless-app[bot]5 months ago453assistant = await response.parse()
454assert_matches_type(Assistant, assistant, path=["response"])
86379b44Stainless Bot2 years ago455
456assert cast(Any, response.is_closed) is True
457
023a4e66Stainless Bot2 years ago458@parametrize
98d779fbStainless Bot2 years ago459async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago460with pytest.warns(DeprecationWarning):
461with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
462await async_client.beta.assistants.with_raw_response.update(
463assistant_id="",
464)
023a4e66Stainless Bot2 years ago465
baa9f07fRobert Craigie2 years ago466@parametrize
98d779fbStainless Bot2 years ago467async def test_method_list(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago468with pytest.warns(DeprecationWarning):
469assistant = await async_client.beta.assistants.list()
470
baa9f07fRobert Craigie2 years ago471assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"])
472
473@parametrize
98d779fbStainless Bot2 years ago474async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago475with pytest.warns(DeprecationWarning):
476assistant = await async_client.beta.assistants.list(
477after="after",
478before="before",
479limit=0,
480order="asc",
481)
482
baa9f07fRobert Craigie2 years ago483assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"])
484
485@parametrize
98d779fbStainless Bot2 years ago486async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago487with pytest.warns(DeprecationWarning):
488response = await async_client.beta.assistants.with_raw_response.list()
86379b44Stainless Bot2 years ago489
490assert response.is_closed is True
baa9f07fRobert Craigie2 years ago491assert response.http_request.headers.get("X-Stainless-Lang") == "python"
492assistant = response.parse()
493assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"])
494
86379b44Stainless Bot2 years ago495@parametrize
98d779fbStainless Bot2 years ago496async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago497with pytest.warns(DeprecationWarning):
498async with async_client.beta.assistants.with_streaming_response.list() as response:
499assert not response.is_closed
500assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago501
c4f76b2estainless-app[bot]5 months ago502assistant = await response.parse()
503assert_matches_type(AsyncCursorPage[Assistant], assistant, path=["response"])
86379b44Stainless Bot2 years ago504
505assert cast(Any, response.is_closed) is True
506
baa9f07fRobert Craigie2 years ago507@parametrize
98d779fbStainless Bot2 years ago508async def test_method_delete(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago509with pytest.warns(DeprecationWarning):
510assistant = await async_client.beta.assistants.delete(
511"assistant_id",
512)
513
f5ef2b3aStainless Bot2 years ago514assert_matches_type(AssistantDeleted, assistant, path=["response"])
baa9f07fRobert Craigie2 years ago515
516@parametrize
98d779fbStainless Bot2 years ago517async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago518with pytest.warns(DeprecationWarning):
519response = await async_client.beta.assistants.with_raw_response.delete(
520"assistant_id",
521)
86379b44Stainless Bot2 years ago522
523assert response.is_closed is True
baa9f07fRobert Craigie2 years ago524assert response.http_request.headers.get("X-Stainless-Lang") == "python"
525assistant = response.parse()
f5ef2b3aStainless Bot2 years ago526assert_matches_type(AssistantDeleted, assistant, path=["response"])
86379b44Stainless Bot2 years ago527
528@parametrize
98d779fbStainless Bot2 years ago529async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago530with pytest.warns(DeprecationWarning):
531async with async_client.beta.assistants.with_streaming_response.delete(
532"assistant_id",
533) as response:
534assert not response.is_closed
535assert response.http_request.headers.get("X-Stainless-Lang") == "python"
86379b44Stainless Bot2 years ago536
c4f76b2estainless-app[bot]5 months ago537assistant = await response.parse()
538assert_matches_type(AssistantDeleted, assistant, path=["response"])
86379b44Stainless Bot2 years ago539
540assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago541
542@parametrize
98d779fbStainless Bot2 years ago543async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None:
c4f76b2estainless-app[bot]5 months ago544with pytest.warns(DeprecationWarning):
545with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
546await async_client.beta.assistants.with_raw_response.delete(
547"",
548)