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