openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
tests/api_resources/beta/threads/test_messages.py
473lines · modeblame
5cfb125aStainless Bot2 years ago | 1 | # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
baa9f07fRobert Craigie2 years ago | 2 | |
| 3 | from __future__ import annotations | |
| 4 | | |
| 5 | import os | |
86379b44Stainless Bot2 years ago | 6 | from typing import Any, cast |
baa9f07fRobert Craigie2 years ago | 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 | |
e4a9553eStainless Bot2 years ago | 13 | from openai.types.beta.threads.message import Message |
baa9f07fRobert Craigie2 years ago | 14 | |
| 15 | base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") | |
| 16 | | |
| 17 | | |
| 18 | class TestMessages: | |
98d779fbStainless Bot2 years ago | 19 | parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) |
baa9f07fRobert Craigie2 years ago | 20 | |
| 21 | @parametrize | |
| 22 | def test_method_create(self, client: OpenAI) -> None: | |
| 23 | message = client.beta.threads.messages.create( | |
| 24 | "string", | |
| 25 | content="x", | |
| 26 | role="user", | |
| 27 | ) | |
5429f696Stainless Bot2 years ago | 28 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 29 | |
| 30 | @parametrize | |
| 31 | def test_method_create_with_all_params(self, client: OpenAI) -> None: | |
| 32 | message = client.beta.threads.messages.create( | |
| 33 | "string", | |
| 34 | content="x", | |
| 35 | role="user", | |
5b20698dStainless Bot2 years ago | 36 | attachments=[ |
| 37 | { | |
| 38 | "file_id": "string", | |
f73996b7Stainless Bot2 years ago | 39 | "tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 40 | }, |
| 41 | { | |
| 42 | "file_id": "string", | |
f73996b7Stainless Bot2 years ago | 43 | "tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 44 | }, |
| 45 | { | |
| 46 | "file_id": "string", | |
f73996b7Stainless Bot2 years ago | 47 | "tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 48 | }, |
| 49 | ], | |
baa9f07fRobert Craigie2 years ago | 50 | metadata={}, |
| 51 | ) | |
5429f696Stainless Bot2 years ago | 52 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 53 | |
| 54 | @parametrize | |
| 55 | def test_raw_response_create(self, client: OpenAI) -> None: | |
| 56 | response = client.beta.threads.messages.with_raw_response.create( | |
| 57 | "string", | |
| 58 | content="x", | |
| 59 | role="user", | |
| 60 | ) | |
86379b44Stainless Bot2 years ago | 61 | |
| 62 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 63 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 64 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 65 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 66 | |
86379b44Stainless Bot2 years ago | 67 | @parametrize |
| 68 | def test_streaming_response_create(self, client: OpenAI) -> None: | |
| 69 | with client.beta.threads.messages.with_streaming_response.create( | |
| 70 | "string", | |
| 71 | content="x", | |
| 72 | role="user", | |
| 73 | ) as response: | |
| 74 | assert not response.is_closed | |
| 75 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 76 | | |
| 77 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 78 | assert_matches_type(Message, message, path=["response"]) |
86379b44Stainless Bot2 years ago | 79 | |
| 80 | assert cast(Any, response.is_closed) is True | |
| 81 | | |
023a4e66Stainless Bot2 years ago | 82 | @parametrize |
| 83 | def test_path_params_create(self, client: OpenAI) -> None: | |
| 84 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 85 | client.beta.threads.messages.with_raw_response.create( | |
| 86 | "", | |
| 87 | content="x", | |
| 88 | role="user", | |
| 89 | ) | |
| 90 | | |
baa9f07fRobert Craigie2 years ago | 91 | @parametrize |
| 92 | def test_method_retrieve(self, client: OpenAI) -> None: | |
| 93 | message = client.beta.threads.messages.retrieve( | |
| 94 | "string", | |
| 95 | thread_id="string", | |
| 96 | ) | |
5429f696Stainless Bot2 years ago | 97 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 98 | |
| 99 | @parametrize | |
| 100 | def test_raw_response_retrieve(self, client: OpenAI) -> None: | |
| 101 | response = client.beta.threads.messages.with_raw_response.retrieve( | |
| 102 | "string", | |
| 103 | thread_id="string", | |
| 104 | ) | |
86379b44Stainless Bot2 years ago | 105 | |
| 106 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 107 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 108 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 109 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 110 | |
86379b44Stainless Bot2 years ago | 111 | @parametrize |
| 112 | def test_streaming_response_retrieve(self, client: OpenAI) -> None: | |
| 113 | with client.beta.threads.messages.with_streaming_response.retrieve( | |
| 114 | "string", | |
| 115 | thread_id="string", | |
| 116 | ) as response: | |
| 117 | assert not response.is_closed | |
| 118 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 119 | | |
| 120 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 121 | assert_matches_type(Message, message, path=["response"]) |
86379b44Stainless Bot2 years ago | 122 | |
| 123 | assert cast(Any, response.is_closed) is True | |
| 124 | | |
023a4e66Stainless Bot2 years ago | 125 | @parametrize |
| 126 | def test_path_params_retrieve(self, client: OpenAI) -> None: | |
| 127 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 128 | client.beta.threads.messages.with_raw_response.retrieve( | |
| 129 | "string", | |
| 130 | thread_id="", | |
| 131 | ) | |
| 132 | | |
| 133 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): | |
| 134 | client.beta.threads.messages.with_raw_response.retrieve( | |
| 135 | "", | |
| 136 | thread_id="string", | |
| 137 | ) | |
| 138 | | |
baa9f07fRobert Craigie2 years ago | 139 | @parametrize |
| 140 | def test_method_update(self, client: OpenAI) -> None: | |
| 141 | message = client.beta.threads.messages.update( | |
| 142 | "string", | |
| 143 | thread_id="string", | |
| 144 | ) | |
5429f696Stainless Bot2 years ago | 145 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 146 | |
| 147 | @parametrize | |
| 148 | def test_method_update_with_all_params(self, client: OpenAI) -> None: | |
| 149 | message = client.beta.threads.messages.update( | |
| 150 | "string", | |
| 151 | thread_id="string", | |
| 152 | metadata={}, | |
| 153 | ) | |
5429f696Stainless Bot2 years ago | 154 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 155 | |
| 156 | @parametrize | |
| 157 | def test_raw_response_update(self, client: OpenAI) -> None: | |
| 158 | response = client.beta.threads.messages.with_raw_response.update( | |
| 159 | "string", | |
| 160 | thread_id="string", | |
| 161 | ) | |
86379b44Stainless Bot2 years ago | 162 | |
| 163 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 164 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 165 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 166 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 167 | |
86379b44Stainless Bot2 years ago | 168 | @parametrize |
| 169 | def test_streaming_response_update(self, client: OpenAI) -> None: | |
| 170 | with client.beta.threads.messages.with_streaming_response.update( | |
| 171 | "string", | |
| 172 | thread_id="string", | |
| 173 | ) as response: | |
| 174 | assert not response.is_closed | |
| 175 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 176 | | |
| 177 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 178 | assert_matches_type(Message, message, path=["response"]) |
86379b44Stainless Bot2 years ago | 179 | |
| 180 | assert cast(Any, response.is_closed) is True | |
| 181 | | |
023a4e66Stainless Bot2 years ago | 182 | @parametrize |
| 183 | def test_path_params_update(self, client: OpenAI) -> None: | |
| 184 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 185 | client.beta.threads.messages.with_raw_response.update( | |
| 186 | "string", | |
| 187 | thread_id="", | |
| 188 | ) | |
| 189 | | |
| 190 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): | |
| 191 | client.beta.threads.messages.with_raw_response.update( | |
| 192 | "", | |
| 193 | thread_id="string", | |
| 194 | ) | |
| 195 | | |
baa9f07fRobert Craigie2 years ago | 196 | @parametrize |
| 197 | def test_method_list(self, client: OpenAI) -> None: | |
| 198 | message = client.beta.threads.messages.list( | |
| 199 | "string", | |
| 200 | ) | |
5429f696Stainless Bot2 years ago | 201 | assert_matches_type(SyncCursorPage[Message], message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 202 | |
| 203 | @parametrize | |
| 204 | def test_method_list_with_all_params(self, client: OpenAI) -> None: | |
| 205 | message = client.beta.threads.messages.list( | |
| 206 | "string", | |
| 207 | after="string", | |
| 208 | before="string", | |
| 209 | limit=0, | |
| 210 | order="asc", | |
8efca3a3Stainless Bot2 years ago | 211 | run_id="string", |
baa9f07fRobert Craigie2 years ago | 212 | ) |
5429f696Stainless Bot2 years ago | 213 | assert_matches_type(SyncCursorPage[Message], message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 214 | |
| 215 | @parametrize | |
| 216 | def test_raw_response_list(self, client: OpenAI) -> None: | |
| 217 | response = client.beta.threads.messages.with_raw_response.list( | |
| 218 | "string", | |
| 219 | ) | |
86379b44Stainless Bot2 years ago | 220 | |
| 221 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 222 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 223 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 224 | assert_matches_type(SyncCursorPage[Message], message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 225 | |
86379b44Stainless Bot2 years ago | 226 | @parametrize |
| 227 | def test_streaming_response_list(self, client: OpenAI) -> None: | |
| 228 | with client.beta.threads.messages.with_streaming_response.list( | |
| 229 | "string", | |
| 230 | ) as response: | |
| 231 | assert not response.is_closed | |
| 232 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 233 | | |
| 234 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 235 | assert_matches_type(SyncCursorPage[Message], message, path=["response"]) |
86379b44Stainless Bot2 years ago | 236 | |
| 237 | assert cast(Any, response.is_closed) is True | |
| 238 | | |
023a4e66Stainless Bot2 years ago | 239 | @parametrize |
| 240 | def test_path_params_list(self, client: OpenAI) -> None: | |
| 241 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): | |
| 242 | client.beta.threads.messages.with_raw_response.list( | |
| 243 | "", | |
| 244 | ) | |
| 245 | | |
baa9f07fRobert Craigie2 years ago | 246 | |
| 247 | class TestAsyncMessages: | |
98d779fbStainless Bot2 years ago | 248 | parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) |
baa9f07fRobert Craigie2 years ago | 249 | |
| 250 | @parametrize | |
98d779fbStainless Bot2 years ago | 251 | async def test_method_create(self, async_client: AsyncOpenAI) -> None: |
| 252 | message = await async_client.beta.threads.messages.create( | |
baa9f07fRobert Craigie2 years ago | 253 | "string", |
| 254 | content="x", | |
| 255 | role="user", | |
| 256 | ) | |
5429f696Stainless Bot2 years ago | 257 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 258 | |
| 259 | @parametrize | |
98d779fbStainless Bot2 years ago | 260 | async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 261 | message = await async_client.beta.threads.messages.create( | |
baa9f07fRobert Craigie2 years ago | 262 | "string", |
| 263 | content="x", | |
| 264 | role="user", | |
5b20698dStainless Bot2 years ago | 265 | attachments=[ |
| 266 | { | |
| 267 | "file_id": "string", | |
f73996b7Stainless Bot2 years ago | 268 | "tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 269 | }, |
| 270 | { | |
| 271 | "file_id": "string", | |
f73996b7Stainless Bot2 years ago | 272 | "tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 273 | }, |
| 274 | { | |
| 275 | "file_id": "string", | |
f73996b7Stainless Bot2 years ago | 276 | "tools": [{"type": "code_interpreter"}, {"type": "code_interpreter"}, {"type": "code_interpreter"}], |
5b20698dStainless Bot2 years ago | 277 | }, |
| 278 | ], | |
baa9f07fRobert Craigie2 years ago | 279 | metadata={}, |
| 280 | ) | |
5429f696Stainless Bot2 years ago | 281 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 282 | |
| 283 | @parametrize | |
98d779fbStainless Bot2 years ago | 284 | async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: |
| 285 | response = await async_client.beta.threads.messages.with_raw_response.create( | |
baa9f07fRobert Craigie2 years ago | 286 | "string", |
| 287 | content="x", | |
| 288 | role="user", | |
| 289 | ) | |
86379b44Stainless Bot2 years ago | 290 | |
| 291 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 292 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 293 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 294 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 295 | |
86379b44Stainless Bot2 years ago | 296 | @parametrize |
98d779fbStainless Bot2 years ago | 297 | async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: |
| 298 | async with async_client.beta.threads.messages.with_streaming_response.create( | |
86379b44Stainless Bot2 years ago | 299 | "string", |
| 300 | content="x", | |
| 301 | role="user", | |
| 302 | ) as response: | |
| 303 | assert not response.is_closed | |
| 304 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 305 | | |
| 306 | message = await response.parse() | |
5429f696Stainless Bot2 years ago | 307 | assert_matches_type(Message, message, path=["response"]) |
86379b44Stainless Bot2 years ago | 308 | |
| 309 | assert cast(Any, response.is_closed) is True | |
| 310 | | |
023a4e66Stainless Bot2 years ago | 311 | @parametrize |
98d779fbStainless Bot2 years ago | 312 | async def test_path_params_create(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 313 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 314 | await async_client.beta.threads.messages.with_raw_response.create( |
023a4e66Stainless Bot2 years ago | 315 | "", |
| 316 | content="x", | |
| 317 | role="user", | |
| 318 | ) | |
| 319 | | |
baa9f07fRobert Craigie2 years ago | 320 | @parametrize |
98d779fbStainless Bot2 years ago | 321 | async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 322 | message = await async_client.beta.threads.messages.retrieve( | |
baa9f07fRobert Craigie2 years ago | 323 | "string", |
| 324 | thread_id="string", | |
| 325 | ) | |
5429f696Stainless Bot2 years ago | 326 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 327 | |
| 328 | @parametrize | |
98d779fbStainless Bot2 years ago | 329 | async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 330 | response = await async_client.beta.threads.messages.with_raw_response.retrieve( | |
baa9f07fRobert Craigie2 years ago | 331 | "string", |
| 332 | thread_id="string", | |
| 333 | ) | |
86379b44Stainless Bot2 years ago | 334 | |
| 335 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 336 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 337 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 338 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 339 | |
86379b44Stainless Bot2 years ago | 340 | @parametrize |
98d779fbStainless Bot2 years ago | 341 | async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: |
| 342 | async with async_client.beta.threads.messages.with_streaming_response.retrieve( | |
86379b44Stainless Bot2 years ago | 343 | "string", |
| 344 | thread_id="string", | |
| 345 | ) as response: | |
| 346 | assert not response.is_closed | |
| 347 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 348 | | |
| 349 | message = await response.parse() | |
5429f696Stainless Bot2 years ago | 350 | assert_matches_type(Message, message, path=["response"]) |
86379b44Stainless Bot2 years ago | 351 | |
| 352 | assert cast(Any, response.is_closed) is True | |
| 353 | | |
023a4e66Stainless Bot2 years ago | 354 | @parametrize |
98d779fbStainless Bot2 years ago | 355 | async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 356 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 357 | await async_client.beta.threads.messages.with_raw_response.retrieve( |
023a4e66Stainless Bot2 years ago | 358 | "string", |
| 359 | thread_id="", | |
| 360 | ) | |
| 361 | | |
| 362 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): | |
98d779fbStainless Bot2 years ago | 363 | await async_client.beta.threads.messages.with_raw_response.retrieve( |
023a4e66Stainless Bot2 years ago | 364 | "", |
| 365 | thread_id="string", | |
| 366 | ) | |
| 367 | | |
baa9f07fRobert Craigie2 years ago | 368 | @parametrize |
98d779fbStainless Bot2 years ago | 369 | async def test_method_update(self, async_client: AsyncOpenAI) -> None: |
| 370 | message = await async_client.beta.threads.messages.update( | |
baa9f07fRobert Craigie2 years ago | 371 | "string", |
| 372 | thread_id="string", | |
| 373 | ) | |
5429f696Stainless Bot2 years ago | 374 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 375 | |
| 376 | @parametrize | |
98d779fbStainless Bot2 years ago | 377 | async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 378 | message = await async_client.beta.threads.messages.update( | |
baa9f07fRobert Craigie2 years ago | 379 | "string", |
| 380 | thread_id="string", | |
| 381 | metadata={}, | |
| 382 | ) | |
5429f696Stainless Bot2 years ago | 383 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 384 | |
| 385 | @parametrize | |
98d779fbStainless Bot2 years ago | 386 | async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None: |
| 387 | response = await async_client.beta.threads.messages.with_raw_response.update( | |
baa9f07fRobert Craigie2 years ago | 388 | "string", |
| 389 | thread_id="string", | |
| 390 | ) | |
86379b44Stainless Bot2 years ago | 391 | |
| 392 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 393 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 394 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 395 | assert_matches_type(Message, message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 396 | |
86379b44Stainless Bot2 years ago | 397 | @parametrize |
98d779fbStainless Bot2 years ago | 398 | async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None: |
| 399 | async with async_client.beta.threads.messages.with_streaming_response.update( | |
86379b44Stainless Bot2 years ago | 400 | "string", |
| 401 | thread_id="string", | |
| 402 | ) as response: | |
| 403 | assert not response.is_closed | |
| 404 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 405 | | |
| 406 | message = await response.parse() | |
5429f696Stainless Bot2 years ago | 407 | assert_matches_type(Message, message, path=["response"]) |
86379b44Stainless Bot2 years ago | 408 | |
| 409 | assert cast(Any, response.is_closed) is True | |
| 410 | | |
023a4e66Stainless Bot2 years ago | 411 | @parametrize |
98d779fbStainless Bot2 years ago | 412 | async def test_path_params_update(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 413 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 414 | await async_client.beta.threads.messages.with_raw_response.update( |
023a4e66Stainless Bot2 years ago | 415 | "string", |
| 416 | thread_id="", | |
| 417 | ) | |
| 418 | | |
| 419 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `message_id` but received ''"): | |
98d779fbStainless Bot2 years ago | 420 | await async_client.beta.threads.messages.with_raw_response.update( |
023a4e66Stainless Bot2 years ago | 421 | "", |
| 422 | thread_id="string", | |
| 423 | ) | |
| 424 | | |
baa9f07fRobert Craigie2 years ago | 425 | @parametrize |
98d779fbStainless Bot2 years ago | 426 | async def test_method_list(self, async_client: AsyncOpenAI) -> None: |
| 427 | message = await async_client.beta.threads.messages.list( | |
baa9f07fRobert Craigie2 years ago | 428 | "string", |
| 429 | ) | |
5429f696Stainless Bot2 years ago | 430 | assert_matches_type(AsyncCursorPage[Message], message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 431 | |
| 432 | @parametrize | |
98d779fbStainless Bot2 years ago | 433 | async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: |
| 434 | message = await async_client.beta.threads.messages.list( | |
baa9f07fRobert Craigie2 years ago | 435 | "string", |
| 436 | after="string", | |
| 437 | before="string", | |
| 438 | limit=0, | |
| 439 | order="asc", | |
8efca3a3Stainless Bot2 years ago | 440 | run_id="string", |
baa9f07fRobert Craigie2 years ago | 441 | ) |
5429f696Stainless Bot2 years ago | 442 | assert_matches_type(AsyncCursorPage[Message], message, path=["response"]) |
baa9f07fRobert Craigie2 years ago | 443 | |
| 444 | @parametrize | |
98d779fbStainless Bot2 years ago | 445 | async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: |
| 446 | response = await async_client.beta.threads.messages.with_raw_response.list( | |
baa9f07fRobert Craigie2 years ago | 447 | "string", |
| 448 | ) | |
86379b44Stainless Bot2 years ago | 449 | |
| 450 | assert response.is_closed is True | |
baa9f07fRobert Craigie2 years ago | 451 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 452 | message = response.parse() | |
5429f696Stainless Bot2 years ago | 453 | assert_matches_type(AsyncCursorPage[Message], message, path=["response"]) |
86379b44Stainless Bot2 years ago | 454 | |
| 455 | @parametrize | |
98d779fbStainless Bot2 years ago | 456 | async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: |
| 457 | async with async_client.beta.threads.messages.with_streaming_response.list( | |
86379b44Stainless Bot2 years ago | 458 | "string", |
| 459 | ) as response: | |
| 460 | assert not response.is_closed | |
| 461 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 462 | | |
| 463 | message = await response.parse() | |
5429f696Stainless Bot2 years ago | 464 | assert_matches_type(AsyncCursorPage[Message], message, path=["response"]) |
86379b44Stainless Bot2 years ago | 465 | |
| 466 | assert cast(Any, response.is_closed) is True | |
023a4e66Stainless Bot2 years ago | 467 | |
| 468 | @parametrize | |
98d779fbStainless Bot2 years ago | 469 | async def test_path_params_list(self, async_client: AsyncOpenAI) -> None: |
023a4e66Stainless Bot2 years ago | 470 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `thread_id` but received ''"): |
98d779fbStainless Bot2 years ago | 471 | await async_client.beta.threads.messages.with_raw_response.list( |
023a4e66Stainless Bot2 years ago | 472 | "", |
| 473 | ) |