openai/openai-python
Publicmirrored fromhttps://github.com/openai/openai-pythonAvailable
tests/api_resources/beta/threads/test_runs.py
645lines · modecode
| 1 | # File generated from our OpenAPI spec by Stainless. |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import os |
| 6 | from typing import Any, cast |
| 7 | |
| 8 | import pytest |
| 9 | |
| 10 | from openai import OpenAI, AsyncOpenAI |
| 11 | from tests.utils import assert_matches_type |
| 12 | from openai.pagination import SyncCursorPage, AsyncCursorPage |
| 13 | from openai.types.beta.threads import ( |
| 14 | Run, |
| 15 | ) |
| 16 | |
| 17 | base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") |
| 18 | |
| 19 | |
| 20 | class TestRuns: |
| 21 | parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) |
| 22 | |
| 23 | @parametrize |
| 24 | def test_method_create(self, client: OpenAI) -> None: |
| 25 | run = client.beta.threads.runs.create( |
| 26 | "string", |
| 27 | assistant_id="string", |
| 28 | ) |
| 29 | assert_matches_type(Run, run, path=["response"]) |
| 30 | |
| 31 | @parametrize |
| 32 | def test_method_create_with_all_params(self, client: OpenAI) -> None: |
| 33 | run = client.beta.threads.runs.create( |
| 34 | "string", |
| 35 | assistant_id="string", |
| 36 | additional_instructions="string", |
| 37 | instructions="string", |
| 38 | metadata={}, |
| 39 | model="string", |
| 40 | tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
| 41 | ) |
| 42 | assert_matches_type(Run, run, path=["response"]) |
| 43 | |
| 44 | @parametrize |
| 45 | def test_raw_response_create(self, client: OpenAI) -> None: |
| 46 | response = client.beta.threads.runs.with_raw_response.create( |
| 47 | "string", |
| 48 | assistant_id="string", |
| 49 | ) |
| 50 | |
| 51 | assert response.is_closed is True |
| 52 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 53 | run = response.parse() |
| 54 | assert_matches_type(Run, run, path=["response"]) |
| 55 | |
| 56 | @parametrize |
| 57 | def test_streaming_response_create(self, client: OpenAI) -> None: |
| 58 | with client.beta.threads.runs.with_streaming_response.create( |
| 59 | "string", |
| 60 | assistant_id="string", |
| 61 | ) as response: |
| 62 | assert not response.is_closed |
| 63 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 64 | |
| 65 | run = response.parse() |
| 66 | assert_matches_type(Run, run, path=["response"]) |
| 67 | |
| 68 | assert cast(Any, response.is_closed) is True |
| 69 | |
| 70 | @parametrize |
| 71 | def test_path_params_create(self, client: OpenAI) -> None: |
| 72 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 73 | client.beta.threads.runs.with_raw_response.create( |
| 74 | "", |
| 75 | assistant_id="string", |
| 76 | ) |
| 77 | |
| 78 | @parametrize |
| 79 | def test_method_retrieve(self, client: OpenAI) -> None: |
| 80 | run = client.beta.threads.runs.retrieve( |
| 81 | "string", |
| 82 | thread_id="string", |
| 83 | ) |
| 84 | assert_matches_type(Run, run, path=["response"]) |
| 85 | |
| 86 | @parametrize |
| 87 | def test_raw_response_retrieve(self, client: OpenAI) -> None: |
| 88 | response = client.beta.threads.runs.with_raw_response.retrieve( |
| 89 | "string", |
| 90 | thread_id="string", |
| 91 | ) |
| 92 | |
| 93 | assert response.is_closed is True |
| 94 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 95 | run = response.parse() |
| 96 | assert_matches_type(Run, run, path=["response"]) |
| 97 | |
| 98 | @parametrize |
| 99 | def test_streaming_response_retrieve(self, client: OpenAI) -> None: |
| 100 | with client.beta.threads.runs.with_streaming_response.retrieve( |
| 101 | "string", |
| 102 | thread_id="string", |
| 103 | ) as response: |
| 104 | assert not response.is_closed |
| 105 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 106 | |
| 107 | run = response.parse() |
| 108 | assert_matches_type(Run, run, path=["response"]) |
| 109 | |
| 110 | assert cast(Any, response.is_closed) is True |
| 111 | |
| 112 | @parametrize |
| 113 | def test_path_params_retrieve(self, client: OpenAI) -> None: |
| 114 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 115 | client.beta.threads.runs.with_raw_response.retrieve( |
| 116 | "string", |
| 117 | thread_id="", |
| 118 | ) |
| 119 | |
| 120 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 121 | client.beta.threads.runs.with_raw_response.retrieve( |
| 122 | "", |
| 123 | thread_id="string", |
| 124 | ) |
| 125 | |
| 126 | @parametrize |
| 127 | def test_method_update(self, client: OpenAI) -> None: |
| 128 | run = client.beta.threads.runs.update( |
| 129 | "string", |
| 130 | thread_id="string", |
| 131 | ) |
| 132 | assert_matches_type(Run, run, path=["response"]) |
| 133 | |
| 134 | @parametrize |
| 135 | def test_method_update_with_all_params(self, client: OpenAI) -> None: |
| 136 | run = client.beta.threads.runs.update( |
| 137 | "string", |
| 138 | thread_id="string", |
| 139 | metadata={}, |
| 140 | ) |
| 141 | assert_matches_type(Run, run, path=["response"]) |
| 142 | |
| 143 | @parametrize |
| 144 | def test_raw_response_update(self, client: OpenAI) -> None: |
| 145 | response = client.beta.threads.runs.with_raw_response.update( |
| 146 | "string", |
| 147 | thread_id="string", |
| 148 | ) |
| 149 | |
| 150 | assert response.is_closed is True |
| 151 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 152 | run = response.parse() |
| 153 | assert_matches_type(Run, run, path=["response"]) |
| 154 | |
| 155 | @parametrize |
| 156 | def test_streaming_response_update(self, client: OpenAI) -> None: |
| 157 | with client.beta.threads.runs.with_streaming_response.update( |
| 158 | "string", |
| 159 | thread_id="string", |
| 160 | ) as response: |
| 161 | assert not response.is_closed |
| 162 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 163 | |
| 164 | run = response.parse() |
| 165 | assert_matches_type(Run, run, path=["response"]) |
| 166 | |
| 167 | assert cast(Any, response.is_closed) is True |
| 168 | |
| 169 | @parametrize |
| 170 | def test_path_params_update(self, client: OpenAI) -> None: |
| 171 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 172 | client.beta.threads.runs.with_raw_response.update( |
| 173 | "string", |
| 174 | thread_id="", |
| 175 | ) |
| 176 | |
| 177 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 178 | client.beta.threads.runs.with_raw_response.update( |
| 179 | "", |
| 180 | thread_id="string", |
| 181 | ) |
| 182 | |
| 183 | @parametrize |
| 184 | def test_method_list(self, client: OpenAI) -> None: |
| 185 | run = client.beta.threads.runs.list( |
| 186 | "string", |
| 187 | ) |
| 188 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) |
| 189 | |
| 190 | @parametrize |
| 191 | def test_method_list_with_all_params(self, client: OpenAI) -> None: |
| 192 | run = client.beta.threads.runs.list( |
| 193 | "string", |
| 194 | after="string", |
| 195 | before="string", |
| 196 | limit=0, |
| 197 | order="asc", |
| 198 | ) |
| 199 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) |
| 200 | |
| 201 | @parametrize |
| 202 | def test_raw_response_list(self, client: OpenAI) -> None: |
| 203 | response = client.beta.threads.runs.with_raw_response.list( |
| 204 | "string", |
| 205 | ) |
| 206 | |
| 207 | assert response.is_closed is True |
| 208 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 209 | run = response.parse() |
| 210 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) |
| 211 | |
| 212 | @parametrize |
| 213 | def test_streaming_response_list(self, client: OpenAI) -> None: |
| 214 | with client.beta.threads.runs.with_streaming_response.list( |
| 215 | "string", |
| 216 | ) as response: |
| 217 | assert not response.is_closed |
| 218 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 219 | |
| 220 | run = response.parse() |
| 221 | assert_matches_type(SyncCursorPage[Run], run, path=["response"]) |
| 222 | |
| 223 | assert cast(Any, response.is_closed) is True |
| 224 | |
| 225 | @parametrize |
| 226 | def test_path_params_list(self, client: OpenAI) -> None: |
| 227 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 228 | client.beta.threads.runs.with_raw_response.list( |
| 229 | "", |
| 230 | ) |
| 231 | |
| 232 | @parametrize |
| 233 | def test_method_cancel(self, client: OpenAI) -> None: |
| 234 | run = client.beta.threads.runs.cancel( |
| 235 | "string", |
| 236 | thread_id="string", |
| 237 | ) |
| 238 | assert_matches_type(Run, run, path=["response"]) |
| 239 | |
| 240 | @parametrize |
| 241 | def test_raw_response_cancel(self, client: OpenAI) -> None: |
| 242 | response = client.beta.threads.runs.with_raw_response.cancel( |
| 243 | "string", |
| 244 | thread_id="string", |
| 245 | ) |
| 246 | |
| 247 | assert response.is_closed is True |
| 248 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 249 | run = response.parse() |
| 250 | assert_matches_type(Run, run, path=["response"]) |
| 251 | |
| 252 | @parametrize |
| 253 | def test_streaming_response_cancel(self, client: OpenAI) -> None: |
| 254 | with client.beta.threads.runs.with_streaming_response.cancel( |
| 255 | "string", |
| 256 | thread_id="string", |
| 257 | ) as response: |
| 258 | assert not response.is_closed |
| 259 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 260 | |
| 261 | run = response.parse() |
| 262 | assert_matches_type(Run, run, path=["response"]) |
| 263 | |
| 264 | assert cast(Any, response.is_closed) is True |
| 265 | |
| 266 | @parametrize |
| 267 | def test_path_params_cancel(self, client: OpenAI) -> None: |
| 268 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 269 | client.beta.threads.runs.with_raw_response.cancel( |
| 270 | "string", |
| 271 | thread_id="", |
| 272 | ) |
| 273 | |
| 274 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 275 | client.beta.threads.runs.with_raw_response.cancel( |
| 276 | "", |
| 277 | thread_id="string", |
| 278 | ) |
| 279 | |
| 280 | @parametrize |
| 281 | def test_method_submit_tool_outputs(self, client: OpenAI) -> None: |
| 282 | run = client.beta.threads.runs.submit_tool_outputs( |
| 283 | "string", |
| 284 | thread_id="string", |
| 285 | tool_outputs=[{}, {}, {}], |
| 286 | ) |
| 287 | assert_matches_type(Run, run, path=["response"]) |
| 288 | |
| 289 | @parametrize |
| 290 | def test_raw_response_submit_tool_outputs(self, client: OpenAI) -> None: |
| 291 | response = client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
| 292 | "string", |
| 293 | thread_id="string", |
| 294 | tool_outputs=[{}, {}, {}], |
| 295 | ) |
| 296 | |
| 297 | assert response.is_closed is True |
| 298 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 299 | run = response.parse() |
| 300 | assert_matches_type(Run, run, path=["response"]) |
| 301 | |
| 302 | @parametrize |
| 303 | def test_streaming_response_submit_tool_outputs(self, client: OpenAI) -> None: |
| 304 | with client.beta.threads.runs.with_streaming_response.submit_tool_outputs( |
| 305 | "string", |
| 306 | thread_id="string", |
| 307 | tool_outputs=[{}, {}, {}], |
| 308 | ) as response: |
| 309 | assert not response.is_closed |
| 310 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 311 | |
| 312 | run = response.parse() |
| 313 | assert_matches_type(Run, run, path=["response"]) |
| 314 | |
| 315 | assert cast(Any, response.is_closed) is True |
| 316 | |
| 317 | @parametrize |
| 318 | def test_path_params_submit_tool_outputs(self, client: OpenAI) -> None: |
| 319 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 320 | client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
| 321 | "string", |
| 322 | thread_id="", |
| 323 | tool_outputs=[{}, {}, {}], |
| 324 | ) |
| 325 | |
| 326 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 327 | client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
| 328 | "", |
| 329 | thread_id="string", |
| 330 | tool_outputs=[{}, {}, {}], |
| 331 | ) |
| 332 | |
| 333 | |
| 334 | class TestAsyncRuns: |
| 335 | parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) |
| 336 | |
| 337 | @parametrize |
| 338 | async def test_method_create(self, async_client: AsyncOpenAI) -> None: |
| 339 | run = await async_client.beta.threads.runs.create( |
| 340 | "string", |
| 341 | assistant_id="string", |
| 342 | ) |
| 343 | assert_matches_type(Run, run, path=["response"]) |
| 344 | |
| 345 | @parametrize |
| 346 | async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 347 | run = await async_client.beta.threads.runs.create( |
| 348 | "string", |
| 349 | assistant_id="string", |
| 350 | additional_instructions="string", |
| 351 | instructions="string", |
| 352 | metadata={}, |
| 353 | model="string", |
| 354 | tools=[{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
| 355 | ) |
| 356 | assert_matches_type(Run, run, path=["response"]) |
| 357 | |
| 358 | @parametrize |
| 359 | async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: |
| 360 | response = await async_client.beta.threads.runs.with_raw_response.create( |
| 361 | "string", |
| 362 | assistant_id="string", |
| 363 | ) |
| 364 | |
| 365 | assert response.is_closed is True |
| 366 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 367 | run = response.parse() |
| 368 | assert_matches_type(Run, run, path=["response"]) |
| 369 | |
| 370 | @parametrize |
| 371 | async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: |
| 372 | async with async_client.beta.threads.runs.with_streaming_response.create( |
| 373 | "string", |
| 374 | assistant_id="string", |
| 375 | ) as response: |
| 376 | assert not response.is_closed |
| 377 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 378 | |
| 379 | run = await response.parse() |
| 380 | assert_matches_type(Run, run, path=["response"]) |
| 381 | |
| 382 | assert cast(Any, response.is_closed) is True |
| 383 | |
| 384 | @parametrize |
| 385 | async def test_path_params_create(self, async_client: AsyncOpenAI) -> None: |
| 386 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 387 | await async_client.beta.threads.runs.with_raw_response.create( |
| 388 | "", |
| 389 | assistant_id="string", |
| 390 | ) |
| 391 | |
| 392 | @parametrize |
| 393 | async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 394 | run = await async_client.beta.threads.runs.retrieve( |
| 395 | "string", |
| 396 | thread_id="string", |
| 397 | ) |
| 398 | assert_matches_type(Run, run, path=["response"]) |
| 399 | |
| 400 | @parametrize |
| 401 | async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 402 | response = await async_client.beta.threads.runs.with_raw_response.retrieve( |
| 403 | "string", |
| 404 | thread_id="string", |
| 405 | ) |
| 406 | |
| 407 | assert response.is_closed is True |
| 408 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 409 | run = response.parse() |
| 410 | assert_matches_type(Run, run, path=["response"]) |
| 411 | |
| 412 | @parametrize |
| 413 | async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 414 | async with async_client.beta.threads.runs.with_streaming_response.retrieve( |
| 415 | "string", |
| 416 | thread_id="string", |
| 417 | ) as response: |
| 418 | assert not response.is_closed |
| 419 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 420 | |
| 421 | run = await response.parse() |
| 422 | assert_matches_type(Run, run, path=["response"]) |
| 423 | |
| 424 | assert cast(Any, response.is_closed) is True |
| 425 | |
| 426 | @parametrize |
| 427 | async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 428 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 429 | await async_client.beta.threads.runs.with_raw_response.retrieve( |
| 430 | "string", |
| 431 | thread_id="", |
| 432 | ) |
| 433 | |
| 434 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 435 | await async_client.beta.threads.runs.with_raw_response.retrieve( |
| 436 | "", |
| 437 | thread_id="string", |
| 438 | ) |
| 439 | |
| 440 | @parametrize |
| 441 | async def test_method_update(self, async_client: AsyncOpenAI) -> None: |
| 442 | run = await async_client.beta.threads.runs.update( |
| 443 | "string", |
| 444 | thread_id="string", |
| 445 | ) |
| 446 | assert_matches_type(Run, run, path=["response"]) |
| 447 | |
| 448 | @parametrize |
| 449 | async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 450 | run = await async_client.beta.threads.runs.update( |
| 451 | "string", |
| 452 | thread_id="string", |
| 453 | metadata={}, |
| 454 | ) |
| 455 | assert_matches_type(Run, run, path=["response"]) |
| 456 | |
| 457 | @parametrize |
| 458 | async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None: |
| 459 | response = await async_client.beta.threads.runs.with_raw_response.update( |
| 460 | "string", |
| 461 | thread_id="string", |
| 462 | ) |
| 463 | |
| 464 | assert response.is_closed is True |
| 465 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 466 | run = response.parse() |
| 467 | assert_matches_type(Run, run, path=["response"]) |
| 468 | |
| 469 | @parametrize |
| 470 | async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None: |
| 471 | async with async_client.beta.threads.runs.with_streaming_response.update( |
| 472 | "string", |
| 473 | thread_id="string", |
| 474 | ) as response: |
| 475 | assert not response.is_closed |
| 476 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 477 | |
| 478 | run = await response.parse() |
| 479 | assert_matches_type(Run, run, path=["response"]) |
| 480 | |
| 481 | assert cast(Any, response.is_closed) is True |
| 482 | |
| 483 | @parametrize |
| 484 | async def test_path_params_update(self, async_client: AsyncOpenAI) -> None: |
| 485 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 486 | await async_client.beta.threads.runs.with_raw_response.update( |
| 487 | "string", |
| 488 | thread_id="", |
| 489 | ) |
| 490 | |
| 491 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 492 | await async_client.beta.threads.runs.with_raw_response.update( |
| 493 | "", |
| 494 | thread_id="string", |
| 495 | ) |
| 496 | |
| 497 | @parametrize |
| 498 | async def test_method_list(self, async_client: AsyncOpenAI) -> None: |
| 499 | run = await async_client.beta.threads.runs.list( |
| 500 | "string", |
| 501 | ) |
| 502 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) |
| 503 | |
| 504 | @parametrize |
| 505 | async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 506 | run = await async_client.beta.threads.runs.list( |
| 507 | "string", |
| 508 | after="string", |
| 509 | before="string", |
| 510 | limit=0, |
| 511 | order="asc", |
| 512 | ) |
| 513 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) |
| 514 | |
| 515 | @parametrize |
| 516 | async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: |
| 517 | response = await async_client.beta.threads.runs.with_raw_response.list( |
| 518 | "string", |
| 519 | ) |
| 520 | |
| 521 | assert response.is_closed is True |
| 522 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 523 | run = response.parse() |
| 524 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) |
| 525 | |
| 526 | @parametrize |
| 527 | async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: |
| 528 | async with async_client.beta.threads.runs.with_streaming_response.list( |
| 529 | "string", |
| 530 | ) as response: |
| 531 | assert not response.is_closed |
| 532 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 533 | |
| 534 | run = await response.parse() |
| 535 | assert_matches_type(AsyncCursorPage[Run], run, path=["response"]) |
| 536 | |
| 537 | assert cast(Any, response.is_closed) is True |
| 538 | |
| 539 | @parametrize |
| 540 | async def test_path_params_list(self, async_client: AsyncOpenAI) -> None: |
| 541 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 542 | await async_client.beta.threads.runs.with_raw_response.list( |
| 543 | "", |
| 544 | ) |
| 545 | |
| 546 | @parametrize |
| 547 | async def test_method_cancel(self, async_client: AsyncOpenAI) -> None: |
| 548 | run = await async_client.beta.threads.runs.cancel( |
| 549 | "string", |
| 550 | thread_id="string", |
| 551 | ) |
| 552 | assert_matches_type(Run, run, path=["response"]) |
| 553 | |
| 554 | @parametrize |
| 555 | async def test_raw_response_cancel(self, async_client: AsyncOpenAI) -> None: |
| 556 | response = await async_client.beta.threads.runs.with_raw_response.cancel( |
| 557 | "string", |
| 558 | thread_id="string", |
| 559 | ) |
| 560 | |
| 561 | assert response.is_closed is True |
| 562 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 563 | run = response.parse() |
| 564 | assert_matches_type(Run, run, path=["response"]) |
| 565 | |
| 566 | @parametrize |
| 567 | async def test_streaming_response_cancel(self, async_client: AsyncOpenAI) -> None: |
| 568 | async with async_client.beta.threads.runs.with_streaming_response.cancel( |
| 569 | "string", |
| 570 | thread_id="string", |
| 571 | ) as response: |
| 572 | assert not response.is_closed |
| 573 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 574 | |
| 575 | run = await response.parse() |
| 576 | assert_matches_type(Run, run, path=["response"]) |
| 577 | |
| 578 | assert cast(Any, response.is_closed) is True |
| 579 | |
| 580 | @parametrize |
| 581 | async def test_path_params_cancel(self, async_client: AsyncOpenAI) -> None: |
| 582 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 583 | await async_client.beta.threads.runs.with_raw_response.cancel( |
| 584 | "string", |
| 585 | thread_id="", |
| 586 | ) |
| 587 | |
| 588 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 589 | await async_client.beta.threads.runs.with_raw_response.cancel( |
| 590 | "", |
| 591 | thread_id="string", |
| 592 | ) |
| 593 | |
| 594 | @parametrize |
| 595 | async def test_method_submit_tool_outputs(self, async_client: AsyncOpenAI) -> None: |
| 596 | run = await async_client.beta.threads.runs.submit_tool_outputs( |
| 597 | "string", |
| 598 | thread_id="string", |
| 599 | tool_outputs=[{}, {}, {}], |
| 600 | ) |
| 601 | assert_matches_type(Run, run, path=["response"]) |
| 602 | |
| 603 | @parametrize |
| 604 | async def test_raw_response_submit_tool_outputs(self, async_client: AsyncOpenAI) -> None: |
| 605 | response = await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
| 606 | "string", |
| 607 | thread_id="string", |
| 608 | tool_outputs=[{}, {}, {}], |
| 609 | ) |
| 610 | |
| 611 | assert response.is_closed is True |
| 612 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 613 | run = response.parse() |
| 614 | assert_matches_type(Run, run, path=["response"]) |
| 615 | |
| 616 | @parametrize |
| 617 | async def test_streaming_response_submit_tool_outputs(self, async_client: AsyncOpenAI) -> None: |
| 618 | async with async_client.beta.threads.runs.with_streaming_response.submit_tool_outputs( |
| 619 | "string", |
| 620 | thread_id="string", |
| 621 | tool_outputs=[{}, {}, {}], |
| 622 | ) as response: |
| 623 | assert not response.is_closed |
| 624 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 625 | |
| 626 | run = await response.parse() |
| 627 | assert_matches_type(Run, run, path=["response"]) |
| 628 | |
| 629 | assert cast(Any, response.is_closed) is True |
| 630 | |
| 631 | @parametrize |
| 632 | async def test_path_params_submit_tool_outputs(self, async_client: AsyncOpenAI) -> None: |
| 633 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
| 634 | await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
| 635 | "string", |
| 636 | thread_id="", |
| 637 | tool_outputs=[{}, {}, {}], |
| 638 | ) |
| 639 | |
| 640 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `run_id` but received ''"): |
| 641 | await async_client.beta.threads.runs.with_raw_response.submit_tool_outputs( |
| 642 | "", |
| 643 | thread_id="string", |
| 644 | tool_outputs=[{}, {}, {}], |
| 645 | ) |