openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.14.3

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api_resources/beta/threads/test_runs.py

925lines · 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
a47375b7Stainless Bot2 years ago13from openai.types.beta.threads import (
14Run,
15)
baa9f07fRobert Craigie2 years ago16
17base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
18
19
20class TestRuns:
98d779fbStainless Bot2 years ago21parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago22
23@parametrize
5429f696Stainless Bot2 years ago24def test_method_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago25run = client.beta.threads.runs.create(
26"string",
27assistant_id="string",
28)
29assert_matches_type(Run, run, path=["response"])
30
31@parametrize
5429f696Stainless Bot2 years ago32def test_method_create_with_all_params_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago33run = client.beta.threads.runs.create(
34"string",
35assistant_id="string",
53bca49eStainless Bot2 years ago36additional_instructions="string",
baa9f07fRobert Craigie2 years ago37instructions="string",
38metadata={},
39model="string",
5429f696Stainless Bot2 years ago40stream=False,
baa9f07fRobert Craigie2 years ago41tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
42)
43assert_matches_type(Run, run, path=["response"])
44
45@parametrize
5429f696Stainless Bot2 years ago46def test_raw_response_create_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago47response = client.beta.threads.runs.with_raw_response.create(
48"string",
49assistant_id="string",
50)
86379b44Stainless Bot2 years ago51
52assert response.is_closed is True
baa9f07fRobert Craigie2 years ago53assert response.http_request.headers.get("X-Stainless-Lang") == "python"
54run = response.parse()
55assert_matches_type(Run, run, path=["response"])
56
86379b44Stainless Bot2 years ago57@parametrize
5429f696Stainless Bot2 years ago58def test_streaming_response_create_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago59with client.beta.threads.runs.with_streaming_response.create(
60"string",
61assistant_id="string",
62) as response:
63assert not response.is_closed
64assert response.http_request.headers.get("X-Stainless-Lang") == "python"
65
66run = response.parse()
67assert_matches_type(Run, run, path=["response"])
68
69assert cast(Any, response.is_closed) is True
70
023a4e66Stainless Bot2 years ago71@parametrize
5429f696Stainless Bot2 years ago72def test_path_params_create_overload_1(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago73with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
74client.beta.threads.runs.with_raw_response.create(
75"",
76assistant_id="string",
77)
78
5429f696Stainless Bot2 years ago79@parametrize
80def test_method_create_overload_2(self, client: OpenAI) -> None:
81run_stream = client.beta.threads.runs.create(
82"string",
83assistant_id="string",
84stream=True,
85)
86run_stream.response.close()
87
88@parametrize
89def test_method_create_with_all_params_overload_2(self, client: OpenAI) -> None:
90run_stream = client.beta.threads.runs.create(
91"string",
92assistant_id="string",
93stream=True,
94additional_instructions="string",
95instructions="string",
96metadata={},
97model="string",
98tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
99)
100run_stream.response.close()
101
102@parametrize
103def test_raw_response_create_overload_2(self, client: OpenAI) -> None:
104response = client.beta.threads.runs.with_raw_response.create(
105"string",
106assistant_id="string",
107stream=True,
108)
109
110assert response.http_request.headers.get("X-Stainless-Lang") == "python"
111stream = response.parse()
112stream.close()
113
114@parametrize
115def test_streaming_response_create_overload_2(self, client: OpenAI) -> None:
116with client.beta.threads.runs.with_streaming_response.create(
117"string",
118assistant_id="string",
119stream=True,
120) as response:
121assert not response.is_closed
122assert response.http_request.headers.get("X-Stainless-Lang") == "python"
123
124stream = response.parse()
125stream.close()
126
127assert cast(Any, response.is_closed) is True
128
129@parametrize
130def test_path_params_create_overload_2(self, client: OpenAI) -> None:
131with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
132client.beta.threads.runs.with_raw_response.create(
133"",
134assistant_id="string",
135stream=True,
136)
137
baa9f07fRobert Craigie2 years ago138@parametrize
139def test_method_retrieve(self, client: OpenAI) -> None:
140run = client.beta.threads.runs.retrieve(
141"string",
142thread_id="string",
143)
144assert_matches_type(Run, run, path=["response"])
145
146@parametrize
147def test_raw_response_retrieve(self, client: OpenAI) -> None:
148response = client.beta.threads.runs.with_raw_response.retrieve(
149"string",
150thread_id="string",
151)
86379b44Stainless Bot2 years ago152
153assert response.is_closed is True
baa9f07fRobert Craigie2 years ago154assert response.http_request.headers.get("X-Stainless-Lang") == "python"
155run = response.parse()
156assert_matches_type(Run, run, path=["response"])
157
86379b44Stainless Bot2 years ago158@parametrize
159def test_streaming_response_retrieve(self, client: OpenAI) -> None:
160with client.beta.threads.runs.with_streaming_response.retrieve(
161"string",
162thread_id="string",
163) as response:
164assert not response.is_closed
165assert response.http_request.headers.get("X-Stainless-Lang") == "python"
166
167run = response.parse()
168assert_matches_type(Run, run, path=["response"])
169
170assert cast(Any, response.is_closed) is True
171
023a4e66Stainless Bot2 years ago172@parametrize
173def test_path_params_retrieve(self, client: OpenAI) -> None:
174with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
175client.beta.threads.runs.with_raw_response.retrieve(
176"string",
177thread_id="",
178)
179
180with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
181client.beta.threads.runs.with_raw_response.retrieve(
182"",
183thread_id="string",
184)
185
baa9f07fRobert Craigie2 years ago186@parametrize
187def test_method_update(self, client: OpenAI) -> None:
188run = client.beta.threads.runs.update(
189"string",
190thread_id="string",
191)
192assert_matches_type(Run, run, path=["response"])
193
194@parametrize
195def test_method_update_with_all_params(self, client: OpenAI) -> None:
196run = client.beta.threads.runs.update(
197"string",
198thread_id="string",
199metadata={},
200)
201assert_matches_type(Run, run, path=["response"])
202
203@parametrize
204def test_raw_response_update(self, client: OpenAI) -> None:
205response = client.beta.threads.runs.with_raw_response.update(
206"string",
207thread_id="string",
208)
86379b44Stainless Bot2 years ago209
210assert response.is_closed is True
baa9f07fRobert Craigie2 years ago211assert response.http_request.headers.get("X-Stainless-Lang") == "python"
212run = response.parse()
213assert_matches_type(Run, run, path=["response"])
214
86379b44Stainless Bot2 years ago215@parametrize
216def test_streaming_response_update(self, client: OpenAI) -> None:
217with client.beta.threads.runs.with_streaming_response.update(
218"string",
219thread_id="string",
220) as response:
221assert not response.is_closed
222assert response.http_request.headers.get("X-Stainless-Lang") == "python"
223
224run = response.parse()
225assert_matches_type(Run, run, path=["response"])
226
227assert cast(Any, response.is_closed) is True
228
023a4e66Stainless Bot2 years ago229@parametrize
230def test_path_params_update(self, client: OpenAI) -> None:
231with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
232client.beta.threads.runs.with_raw_response.update(
233"string",
234thread_id="",
235)
236
237with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
238client.beta.threads.runs.with_raw_response.update(
239"",
240thread_id="string",
241)
242
baa9f07fRobert Craigie2 years ago243@parametrize
244def test_method_list(self, client: OpenAI) -> None:
245run = client.beta.threads.runs.list(
246"string",
247)
248assert_matches_type(SyncCursorPage[Run], run, path=["response"])
249
250@parametrize
251def test_method_list_with_all_params(self, client: OpenAI) -> None:
252run = client.beta.threads.runs.list(
253"string",
254after="string",
255before="string",
256limit=0,
257order="asc",
258)
259assert_matches_type(SyncCursorPage[Run], run, path=["response"])
260
261@parametrize
262def test_raw_response_list(self, client: OpenAI) -> None:
263response = client.beta.threads.runs.with_raw_response.list(
264"string",
265)
86379b44Stainless Bot2 years ago266
267assert response.is_closed is True
baa9f07fRobert Craigie2 years ago268assert response.http_request.headers.get("X-Stainless-Lang") == "python"
269run = response.parse()
270assert_matches_type(SyncCursorPage[Run], run, path=["response"])
271
86379b44Stainless Bot2 years ago272@parametrize
273def test_streaming_response_list(self, client: OpenAI) -> None:
274with client.beta.threads.runs.with_streaming_response.list(
275"string",
276) as response:
277assert not response.is_closed
278assert response.http_request.headers.get("X-Stainless-Lang") == "python"
279
280run = response.parse()
281assert_matches_type(SyncCursorPage[Run], run, path=["response"])
282
283assert cast(Any, response.is_closed) is True
284
023a4e66Stainless Bot2 years ago285@parametrize
286def test_path_params_list(self, client: OpenAI) -> None:
287with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
288client.beta.threads.runs.with_raw_response.list(
289"",
290)
291
baa9f07fRobert Craigie2 years ago292@parametrize
293def test_method_cancel(self, client: OpenAI) -> None:
294run = client.beta.threads.runs.cancel(
295"string",
296thread_id="string",
297)
298assert_matches_type(Run, run, path=["response"])
299
300@parametrize
301def test_raw_response_cancel(self, client: OpenAI) -> None:
302response = client.beta.threads.runs.with_raw_response.cancel(
303"string",
304thread_id="string",
305)
86379b44Stainless Bot2 years ago306
307assert response.is_closed is True
baa9f07fRobert Craigie2 years ago308assert response.http_request.headers.get("X-Stainless-Lang") == "python"
309run = response.parse()
310assert_matches_type(Run, run, path=["response"])
311
86379b44Stainless Bot2 years ago312@parametrize
313def test_streaming_response_cancel(self, client: OpenAI) -> None:
314with client.beta.threads.runs.with_streaming_response.cancel(
315"string",
316thread_id="string",
317) as response:
318assert not response.is_closed
319assert response.http_request.headers.get("X-Stainless-Lang") == "python"
320
321run = response.parse()
322assert_matches_type(Run, run, path=["response"])
323
324assert cast(Any, response.is_closed) is True
325
023a4e66Stainless Bot2 years ago326@parametrize
327def test_path_params_cancel(self, client: OpenAI) -> None:
328with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
329client.beta.threads.runs.with_raw_response.cancel(
330"string",
331thread_id="",
332)
333
334with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
335client.beta.threads.runs.with_raw_response.cancel(
336"",
337thread_id="string",
338)
339
baa9f07fRobert Craigie2 years ago340@parametrize
5429f696Stainless Bot2 years ago341def test_method_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago342run = client.beta.threads.runs.submit_tool_outputs(
343"string",
344thread_id="string",
345tool_outputs=[{}, {}, {}],
346)
347assert_matches_type(Run, run, path=["response"])
348
349@parametrize
5429f696Stainless Bot2 years ago350def test_method_submit_tool_outputs_with_all_params_overload_1(self, client: OpenAI) -> None:
351run = client.beta.threads.runs.submit_tool_outputs(
352"string",
353thread_id="string",
354tool_outputs=[
355{
356"tool_call_id": "string",
357"output": "string",
358},
359{
360"tool_call_id": "string",
361"output": "string",
362},
363{
364"tool_call_id": "string",
365"output": "string",
366},
367],
368stream=False,
369)
370assert_matches_type(Run, run, path=["response"])
371
372@parametrize
373def test_raw_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
baa9f07fRobert Craigie2 years ago374response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
375"string",
376thread_id="string",
377tool_outputs=[{}, {}, {}],
378)
86379b44Stainless Bot2 years ago379
380assert response.is_closed is True
baa9f07fRobert Craigie2 years ago381assert response.http_request.headers.get("X-Stainless-Lang") == "python"
382run = response.parse()
383assert_matches_type(Run, run, path=["response"])
384
86379b44Stainless Bot2 years ago385@parametrize
5429f696Stainless Bot2 years ago386def test_streaming_response_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
86379b44Stainless Bot2 years ago387with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
388"string",
389thread_id="string",
390tool_outputs=[{}, {}, {}],
391) as response:
392assert not response.is_closed
393assert response.http_request.headers.get("X-Stainless-Lang") == "python"
394
395run = response.parse()
396assert_matches_type(Run, run, path=["response"])
397
398assert cast(Any, response.is_closed) is True
399
023a4e66Stainless Bot2 years ago400@parametrize
5429f696Stainless Bot2 years ago401def test_path_params_submit_tool_outputs_overload_1(self, client: OpenAI) -> None:
402with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
403client.beta.threads.runs.with_raw_response.submit_tool_outputs(
404"string",
405thread_id="",
406tool_outputs=[{}, {}, {}],
407)
408
409with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
410client.beta.threads.runs.with_raw_response.submit_tool_outputs(
411"",
412thread_id="string",
413tool_outputs=[{}, {}, {}],
414)
415
416@parametrize
417def test_method_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
418run_stream = client.beta.threads.runs.submit_tool_outputs(
419"string",
420thread_id="string",
421stream=True,
422tool_outputs=[{}, {}, {}],
423)
424run_stream.response.close()
425
426@parametrize
427def test_raw_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
428response = client.beta.threads.runs.with_raw_response.submit_tool_outputs(
429"string",
430thread_id="string",
431stream=True,
432tool_outputs=[{}, {}, {}],
433)
434
435assert response.http_request.headers.get("X-Stainless-Lang") == "python"
436stream = response.parse()
437stream.close()
438
439@parametrize
440def test_streaming_response_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
441with client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
442"string",
443thread_id="string",
444stream=True,
445tool_outputs=[{}, {}, {}],
446) as response:
447assert not response.is_closed
448assert response.http_request.headers.get("X-Stainless-Lang") == "python"
449
450stream = response.parse()
451stream.close()
452
453assert cast(Any, response.is_closed) is True
454
455@parametrize
456def test_path_params_submit_tool_outputs_overload_2(self, client: OpenAI) -> None:
023a4e66Stainless Bot2 years ago457with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
458client.beta.threads.runs.with_raw_response.submit_tool_outputs(
459"string",
460thread_id="",
5429f696Stainless Bot2 years ago461stream=True,
023a4e66Stainless Bot2 years ago462tool_outputs=[{}, {}, {}],
463)
464
465with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
466client.beta.threads.runs.with_raw_response.submit_tool_outputs(
467"",
468thread_id="string",
5429f696Stainless Bot2 years ago469stream=True,
023a4e66Stainless Bot2 years ago470tool_outputs=[{}, {}, {}],
471)
472
baa9f07fRobert Craigie2 years ago473
474class TestAsyncRuns:
98d779fbStainless Bot2 years ago475parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
baa9f07fRobert Craigie2 years ago476
477@parametrize
5429f696Stainless Bot2 years ago478async def test_method_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago479run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago480"string",
481assistant_id="string",
482)
483assert_matches_type(Run, run, path=["response"])
484
485@parametrize
5429f696Stainless Bot2 years ago486async def test_method_create_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago487run = await async_client.beta.threads.runs.create(
baa9f07fRobert Craigie2 years ago488"string",
489assistant_id="string",
53bca49eStainless Bot2 years ago490additional_instructions="string",
baa9f07fRobert Craigie2 years ago491instructions="string",
492metadata={},
493model="string",
5429f696Stainless Bot2 years ago494stream=False,
baa9f07fRobert Craigie2 years ago495tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
496)
497assert_matches_type(Run, run, path=["response"])
498
499@parametrize
5429f696Stainless Bot2 years ago500async def test_raw_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago501response = await async_client.beta.threads.runs.with_raw_response.create(
baa9f07fRobert Craigie2 years ago502"string",
503assistant_id="string",
504)
86379b44Stainless Bot2 years ago505
506assert response.is_closed is True
baa9f07fRobert Craigie2 years ago507assert response.http_request.headers.get("X-Stainless-Lang") == "python"
508run = response.parse()
509assert_matches_type(Run, run, path=["response"])
510
86379b44Stainless Bot2 years ago511@parametrize
5429f696Stainless Bot2 years ago512async def test_streaming_response_create_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago513async with async_client.beta.threads.runs.with_streaming_response.create(
86379b44Stainless Bot2 years ago514"string",
515assistant_id="string",
516) as response:
517assert not response.is_closed
518assert response.http_request.headers.get("X-Stainless-Lang") == "python"
519
520run = await response.parse()
521assert_matches_type(Run, run, path=["response"])
522
523assert cast(Any, response.is_closed) is True
524
023a4e66Stainless Bot2 years ago525@parametrize
5429f696Stainless Bot2 years ago526async def test_path_params_create_overload_1(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago527with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago528await async_client.beta.threads.runs.with_raw_response.create(
023a4e66Stainless Bot2 years ago529"",
530assistant_id="string",
531)
532
5429f696Stainless Bot2 years ago533@parametrize
534async def test_method_create_overload_2(self, async_client: AsyncOpenAI) -> None:
535run_stream = await async_client.beta.threads.runs.create(
536"string",
537assistant_id="string",
538stream=True,
539)
540await run_stream.response.aclose()
541
542@parametrize
543async def test_method_create_with_all_params_overload_2(self, async_client: AsyncOpenAI) -> None:
544run_stream = await async_client.beta.threads.runs.create(
545"string",
546assistant_id="string",
547stream=True,
548additional_instructions="string",
549instructions="string",
550metadata={},
551model="string",
552tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}],
553)
554await run_stream.response.aclose()
555
556@parametrize
557async def test_raw_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
558response = await async_client.beta.threads.runs.with_raw_response.create(
559"string",
560assistant_id="string",
561stream=True,
562)
563
564assert response.http_request.headers.get("X-Stainless-Lang") == "python"
565stream = response.parse()
566await stream.close()
567
568@parametrize
569async def test_streaming_response_create_overload_2(self, async_client: AsyncOpenAI) -> None:
570async with async_client.beta.threads.runs.with_streaming_response.create(
571"string",
572assistant_id="string",
573stream=True,
574) as response:
575assert not response.is_closed
576assert response.http_request.headers.get("X-Stainless-Lang") == "python"
577
578stream = await response.parse()
579await stream.close()
580
581assert cast(Any, response.is_closed) is True
582
583@parametrize
584async def test_path_params_create_overload_2(self, async_client: AsyncOpenAI) -> None:
585with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
586await async_client.beta.threads.runs.with_raw_response.create(
587"",
588assistant_id="string",
589stream=True,
590)
591
baa9f07fRobert Craigie2 years ago592@parametrize
98d779fbStainless Bot2 years ago593async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
594run = await async_client.beta.threads.runs.retrieve(
baa9f07fRobert Craigie2 years ago595"string",
596thread_id="string",
597)
598assert_matches_type(Run, run, path=["response"])
599
600@parametrize
98d779fbStainless Bot2 years ago601async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
602response = await async_client.beta.threads.runs.with_raw_response.retrieve(
baa9f07fRobert Craigie2 years ago603"string",
604thread_id="string",
605)
86379b44Stainless Bot2 years ago606
607assert response.is_closed is True
baa9f07fRobert Craigie2 years ago608assert response.http_request.headers.get("X-Stainless-Lang") == "python"
609run = response.parse()
610assert_matches_type(Run, run, path=["response"])
611
86379b44Stainless Bot2 years ago612@parametrize
98d779fbStainless Bot2 years ago613async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
614async with async_client.beta.threads.runs.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago615"string",
616thread_id="string",
617) as response:
618assert not response.is_closed
619assert response.http_request.headers.get("X-Stainless-Lang") == "python"
620
621run = await response.parse()
622assert_matches_type(Run, run, path=["response"])
623
624assert cast(Any, response.is_closed) is True
625
023a4e66Stainless Bot2 years ago626@parametrize
98d779fbStainless Bot2 years ago627async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago628with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago629await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago630"string",
631thread_id="",
632)
633
634with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago635await async_client.beta.threads.runs.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago636"",
637thread_id="string",
638)
639
baa9f07fRobert Craigie2 years ago640@parametrize
98d779fbStainless Bot2 years ago641async def test_method_update(self, async_client: AsyncOpenAI) -> None:
642run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago643"string",
644thread_id="string",
645)
646assert_matches_type(Run, run, path=["response"])
647
648@parametrize
98d779fbStainless Bot2 years ago649async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
650run = await async_client.beta.threads.runs.update(
baa9f07fRobert Craigie2 years ago651"string",
652thread_id="string",
653metadata={},
654)
655assert_matches_type(Run, run, path=["response"])
656
657@parametrize
98d779fbStainless Bot2 years ago658async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
659response = await async_client.beta.threads.runs.with_raw_response.update(
baa9f07fRobert Craigie2 years ago660"string",
661thread_id="string",
662)
86379b44Stainless Bot2 years ago663
664assert response.is_closed is True
baa9f07fRobert Craigie2 years ago665assert response.http_request.headers.get("X-Stainless-Lang") == "python"
666run = response.parse()
667assert_matches_type(Run, run, path=["response"])
668
86379b44Stainless Bot2 years ago669@parametrize
98d779fbStainless Bot2 years ago670async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
671async with async_client.beta.threads.runs.with_streaming_response.update(
86379b44Stainless Bot2 years ago672"string",
673thread_id="string",
674) as response:
675assert not response.is_closed
676assert response.http_request.headers.get("X-Stainless-Lang") == "python"
677
678run = await response.parse()
679assert_matches_type(Run, run, path=["response"])
680
681assert cast(Any, response.is_closed) is True
682
023a4e66Stainless Bot2 years ago683@parametrize
98d779fbStainless Bot2 years ago684async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago685with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago686await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago687"string",
688thread_id="",
689)
690
691with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago692await async_client.beta.threads.runs.with_raw_response.update(
023a4e66Stainless Bot2 years ago693"",
694thread_id="string",
695)
696
baa9f07fRobert Craigie2 years ago697@parametrize
98d779fbStainless Bot2 years ago698async def test_method_list(self, async_client: AsyncOpenAI) -> None:
699run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago700"string",
701)
702assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
703
704@parametrize
98d779fbStainless Bot2 years ago705async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
706run = await async_client.beta.threads.runs.list(
baa9f07fRobert Craigie2 years ago707"string",
708after="string",
709before="string",
710limit=0,
711order="asc",
712)
713assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
714
715@parametrize
98d779fbStainless Bot2 years ago716async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
717response = await async_client.beta.threads.runs.with_raw_response.list(
baa9f07fRobert Craigie2 years ago718"string",
719)
86379b44Stainless Bot2 years ago720
721assert response.is_closed is True
baa9f07fRobert Craigie2 years ago722assert response.http_request.headers.get("X-Stainless-Lang") == "python"
723run = response.parse()
724assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
725
86379b44Stainless Bot2 years ago726@parametrize
98d779fbStainless Bot2 years ago727async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
728async with async_client.beta.threads.runs.with_streaming_response.list(
86379b44Stainless Bot2 years ago729"string",
730) as response:
731assert not response.is_closed
732assert response.http_request.headers.get("X-Stainless-Lang") == "python"
733
734run = await response.parse()
735assert_matches_type(AsyncCursorPage[Run], run, path=["response"])
736
737assert cast(Any, response.is_closed) is True
738
023a4e66Stainless Bot2 years ago739@parametrize
98d779fbStainless Bot2 years ago740async def test_path_params_list(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago741with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago742await async_client.beta.threads.runs.with_raw_response.list(
023a4e66Stainless Bot2 years ago743"",
744)
745
baa9f07fRobert Craigie2 years ago746@parametrize
98d779fbStainless Bot2 years ago747async def test_method_cancel(self, async_client: AsyncOpenAI) -> None:
748run = await async_client.beta.threads.runs.cancel(
baa9f07fRobert Craigie2 years ago749"string",
750thread_id="string",
751)
752assert_matches_type(Run, run, path=["response"])
753
754@parametrize
98d779fbStainless Bot2 years ago755async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None:
756response = await async_client.beta.threads.runs.with_raw_response.cancel(
baa9f07fRobert Craigie2 years ago757"string",
758thread_id="string",
759)
86379b44Stainless Bot2 years ago760
761assert response.is_closed is True
baa9f07fRobert Craigie2 years ago762assert response.http_request.headers.get("X-Stainless-Lang") == "python"
763run = response.parse()
764assert_matches_type(Run, run, path=["response"])
765
86379b44Stainless Bot2 years ago766@parametrize
98d779fbStainless Bot2 years ago767async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None:
768async with async_client.beta.threads.runs.with_streaming_response.cancel(
86379b44Stainless Bot2 years ago769"string",
770thread_id="string",
771) as response:
772assert not response.is_closed
773assert response.http_request.headers.get("X-Stainless-Lang") == "python"
774
775run = await response.parse()
776assert_matches_type(Run, run, path=["response"])
777
778assert cast(Any, response.is_closed) is True
779
023a4e66Stainless Bot2 years ago780@parametrize
98d779fbStainless Bot2 years ago781async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago782with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago783await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago784"string",
785thread_id="",
786)
787
788with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago789await async_client.beta.threads.runs.with_raw_response.cancel(
023a4e66Stainless Bot2 years ago790"",
791thread_id="string",
792)
793
baa9f07fRobert Craigie2 years ago794@parametrize
5429f696Stainless Bot2 years ago795async def test_method_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago796run = await async_client.beta.threads.runs.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago797"string",
798thread_id="string",
799tool_outputs=[{}, {}, {}],
800)
801assert_matches_type(Run, run, path=["response"])
802
803@parametrize
5429f696Stainless Bot2 years ago804async def test_method_submit_tool_outputs_with_all_params_overload_1(self, async_client: AsyncOpenAI) -> None:
805run = await async_client.beta.threads.runs.submit_tool_outputs(
806"string",
807thread_id="string",
808tool_outputs=[
809{
810"tool_call_id": "string",
811"output": "string",
812},
813{
814"tool_call_id": "string",
815"output": "string",
816},
817{
818"tool_call_id": "string",
819"output": "string",
820},
821],
822stream=False,
823)
824assert_matches_type(Run, run, path=["response"])
825
826@parametrize
827async def test_raw_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago828response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
baa9f07fRobert Craigie2 years ago829"string",
830thread_id="string",
831tool_outputs=[{}, {}, {}],
832)
86379b44Stainless Bot2 years ago833
834assert response.is_closed is True
baa9f07fRobert Craigie2 years ago835assert response.http_request.headers.get("X-Stainless-Lang") == "python"
836run = response.parse()
837assert_matches_type(Run, run, path=["response"])
86379b44Stainless Bot2 years ago838
839@parametrize
5429f696Stainless Bot2 years ago840async def test_streaming_response_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
98d779fbStainless Bot2 years ago841async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
86379b44Stainless Bot2 years ago842"string",
843thread_id="string",
844tool_outputs=[{}, {}, {}],
845) as response:
846assert not response.is_closed
847assert response.http_request.headers.get("X-Stainless-Lang") == "python"
848
849run = await response.parse()
850assert_matches_type(Run, run, path=["response"])
851
852assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago853
854@parametrize
5429f696Stainless Bot2 years ago855async def test_path_params_submit_tool_outputs_overload_1(self, async_client: AsyncOpenAI) -> None:
856with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
857await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
858"string",
859thread_id="",
860tool_outputs=[{}, {}, {}],
861)
862
863with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
864await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
865"",
866thread_id="string",
867tool_outputs=[{}, {}, {}],
868)
869
870@parametrize
871async def test_method_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
872run_stream = await async_client.beta.threads.runs.submit_tool_outputs(
873"string",
874thread_id="string",
875stream=True,
876tool_outputs=[{}, {}, {}],
877)
878await run_stream.response.aclose()
879
880@parametrize
881async def test_raw_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
882response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
883"string",
884thread_id="string",
885stream=True,
886tool_outputs=[{}, {}, {}],
887)
888
889assert response.http_request.headers.get("X-Stainless-Lang") == "python"
890stream = response.parse()
891await stream.close()
892
893@parametrize
894async def test_streaming_response_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
895async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs(
896"string",
897thread_id="string",
898stream=True,
899tool_outputs=[{}, {}, {}],
900) as response:
901assert not response.is_closed
902assert response.http_request.headers.get("X-Stainless-Lang") == "python"
903
904stream = await response.parse()
905await stream.close()
906
907assert cast(Any, response.is_closed) is True
908
909@parametrize
910async def test_path_params_submit_tool_outputs_overload_2(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago911with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"):
98d779fbStainless Bot2 years ago912await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago913"string",
914thread_id="",
5429f696Stainless Bot2 years ago915stream=True,
023a4e66Stainless Bot2 years ago916tool_outputs=[{}, {}, {}],
917)
918
919with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"):
98d779fbStainless Bot2 years ago920await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs(
023a4e66Stainless Bot2 years ago921"",
922thread_id="string",
5429f696Stainless Bot2 years ago923stream=True,
023a4e66Stainless Bot2 years ago924tool_outputs=[{}, {}, {}],
925)