| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import os |
| 4 |
from typing import Any, cast |
| 5 |
|
| 6 |
import pytest |
| 7 |
|
| 8 |
from anthropic import Anthropic, AsyncAnthropic |
| 9 |
from tests.utils import assert_matches_type |
| 10 |
from anthropic._utils import parse_datetime |
| 11 |
from anthropic.pagination import SyncPageCursor, AsyncPageCursor |
| 12 |
from anthropic.types.beta import BetaDream |
| 13 |
|
| 14 |
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") |
| 15 |
|
| 16 |
|
| 17 |
class TestDreams: |
| 18 |
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) |
| 19 |
|
| 20 |
@parametrize |
| 21 |
def test_method_create(self, client: Anthropic) -> None: |
| 22 |
dream = client.beta.dreams.create( |
| 23 |
inputs=[ |
| 24 |
{ |
| 25 |
"memory_store_id": "x", |
| 26 |
"type": "memory_store", |
| 27 |
} |
| 28 |
], |
| 29 |
model="string", |
| 30 |
) |
| 31 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 32 |
|
| 33 |
@parametrize |
| 34 |
def test_method_create_with_all_params(self, client: Anthropic) -> None: |
| 35 |
dream = client.beta.dreams.create( |
| 36 |
inputs=[ |
| 37 |
{ |
| 38 |
"memory_store_id": "x", |
| 39 |
"type": "memory_store", |
| 40 |
} |
| 41 |
], |
| 42 |
model="string", |
| 43 |
instructions="x", |
| 44 |
output_behavior={"type": "create_new"}, |
| 45 |
betas=["message-batches-2024-09-24"], |
| 46 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 47 |
) |
| 48 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 49 |
|
| 50 |
@parametrize |
| 51 |
def test_raw_response_create(self, client: Anthropic) -> None: |
| 52 |
response = client.beta.dreams.with_raw_response.create( |
| 53 |
inputs=[ |
| 54 |
{ |
| 55 |
"memory_store_id": "x", |
| 56 |
"type": "memory_store", |
| 57 |
} |
| 58 |
], |
| 59 |
model="string", |
| 60 |
) |
| 61 |
|
| 62 |
assert response.is_closed is True |
| 63 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 64 |
dream = response.parse() |
| 65 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 66 |
|
| 67 |
@parametrize |
| 68 |
def test_streaming_response_create(self, client: Anthropic) -> None: |
| 69 |
with client.beta.dreams.with_streaming_response.create( |
| 70 |
inputs=[ |
| 71 |
{ |
| 72 |
"memory_store_id": "x", |
| 73 |
"type": "memory_store", |
| 74 |
} |
| 75 |
], |
| 76 |
model="string", |
| 77 |
) as response: |
| 78 |
assert not response.is_closed |
| 79 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 80 |
|
| 81 |
dream = response.parse() |
| 82 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 83 |
|
| 84 |
assert cast(Any, response.is_closed) is True |
| 85 |
|
| 86 |
@parametrize |
| 87 |
def test_method_retrieve(self, client: Anthropic) -> None: |
| 88 |
dream = client.beta.dreams.retrieve( |
| 89 |
dream_id="dream_id", |
| 90 |
) |
| 91 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 92 |
|
| 93 |
@parametrize |
| 94 |
def test_method_retrieve_with_all_params(self, client: Anthropic) -> None: |
| 95 |
dream = client.beta.dreams.retrieve( |
| 96 |
dream_id="dream_id", |
| 97 |
betas=["message-batches-2024-09-24"], |
| 98 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 99 |
) |
| 100 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 101 |
|
| 102 |
@parametrize |
| 103 |
def test_raw_response_retrieve(self, client: Anthropic) -> None: |
| 104 |
response = client.beta.dreams.with_raw_response.retrieve( |
| 105 |
dream_id="dream_id", |
| 106 |
) |
| 107 |
|
| 108 |
assert response.is_closed is True |
| 109 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 110 |
dream = response.parse() |
| 111 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 112 |
|
| 113 |
@parametrize |
| 114 |
def test_streaming_response_retrieve(self, client: Anthropic) -> None: |
| 115 |
with client.beta.dreams.with_streaming_response.retrieve( |
| 116 |
dream_id="dream_id", |
| 117 |
) as response: |
| 118 |
assert not response.is_closed |
| 119 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 120 |
|
| 121 |
dream = response.parse() |
| 122 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 123 |
|
| 124 |
assert cast(Any, response.is_closed) is True |
| 125 |
|
| 126 |
@parametrize |
| 127 |
def test_path_params_retrieve(self, client: Anthropic) -> None: |
| 128 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `dream_id` but received ''"): |
| 129 |
client.beta.dreams.with_raw_response.retrieve( |
| 130 |
dream_id="", |
| 131 |
) |
| 132 |
|
| 133 |
@parametrize |
| 134 |
def test_method_list(self, client: Anthropic) -> None: |
| 135 |
dream = client.beta.dreams.list() |
| 136 |
assert_matches_type(SyncPageCursor[BetaDream], dream, path=["response"]) |
| 137 |
|
| 138 |
@parametrize |
| 139 |
def test_method_list_with_all_params(self, client: Anthropic) -> None: |
| 140 |
dream = client.beta.dreams.list( |
| 141 |
created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 142 |
created_at_lt=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 143 |
include_archived=True, |
| 144 |
limit=0, |
| 145 |
page="page", |
| 146 |
statuses=["pending"], |
| 147 |
betas=["message-batches-2024-09-24"], |
| 148 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 149 |
) |
| 150 |
assert_matches_type(SyncPageCursor[BetaDream], dream, path=["response"]) |
| 151 |
|
| 152 |
@parametrize |
| 153 |
def test_raw_response_list(self, client: Anthropic) -> None: |
| 154 |
response = client.beta.dreams.with_raw_response.list() |
| 155 |
|
| 156 |
assert response.is_closed is True |
| 157 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 158 |
dream = response.parse() |
| 159 |
assert_matches_type(SyncPageCursor[BetaDream], dream, path=["response"]) |
| 160 |
|
| 161 |
@parametrize |
| 162 |
def test_streaming_response_list(self, client: Anthropic) -> None: |
| 163 |
with client.beta.dreams.with_streaming_response.list() as response: |
| 164 |
assert not response.is_closed |
| 165 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 166 |
|
| 167 |
dream = response.parse() |
| 168 |
assert_matches_type(SyncPageCursor[BetaDream], dream, path=["response"]) |
| 169 |
|
| 170 |
assert cast(Any, response.is_closed) is True |
| 171 |
|
| 172 |
@parametrize |
| 173 |
def test_method_archive(self, client: Anthropic) -> None: |
| 174 |
dream = client.beta.dreams.archive( |
| 175 |
dream_id="dream_id", |
| 176 |
) |
| 177 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 178 |
|
| 179 |
@parametrize |
| 180 |
def test_method_archive_with_all_params(self, client: Anthropic) -> None: |
| 181 |
dream = client.beta.dreams.archive( |
| 182 |
dream_id="dream_id", |
| 183 |
betas=["message-batches-2024-09-24"], |
| 184 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 185 |
) |
| 186 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 187 |
|
| 188 |
@parametrize |
| 189 |
def test_raw_response_archive(self, client: Anthropic) -> None: |
| 190 |
response = client.beta.dreams.with_raw_response.archive( |
| 191 |
dream_id="dream_id", |
| 192 |
) |
| 193 |
|
| 194 |
assert response.is_closed is True |
| 195 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 196 |
dream = response.parse() |
| 197 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 198 |
|
| 199 |
@parametrize |
| 200 |
def test_streaming_response_archive(self, client: Anthropic) -> None: |
| 201 |
with client.beta.dreams.with_streaming_response.archive( |
| 202 |
dream_id="dream_id", |
| 203 |
) as response: |
| 204 |
assert not response.is_closed |
| 205 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 206 |
|
| 207 |
dream = response.parse() |
| 208 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 209 |
|
| 210 |
assert cast(Any, response.is_closed) is True |
| 211 |
|
| 212 |
@parametrize |
| 213 |
def test_path_params_archive(self, client: Anthropic) -> None: |
| 214 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `dream_id` but received ''"): |
| 215 |
client.beta.dreams.with_raw_response.archive( |
| 216 |
dream_id="", |
| 217 |
) |
| 218 |
|
| 219 |
@parametrize |
| 220 |
def test_method_cancel(self, client: Anthropic) -> None: |
| 221 |
dream = client.beta.dreams.cancel( |
| 222 |
dream_id="dream_id", |
| 223 |
) |
| 224 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 225 |
|
| 226 |
@parametrize |
| 227 |
def test_method_cancel_with_all_params(self, client: Anthropic) -> None: |
| 228 |
dream = client.beta.dreams.cancel( |
| 229 |
dream_id="dream_id", |
| 230 |
betas=["message-batches-2024-09-24"], |
| 231 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 232 |
) |
| 233 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 234 |
|
| 235 |
@parametrize |
| 236 |
def test_raw_response_cancel(self, client: Anthropic) -> None: |
| 237 |
response = client.beta.dreams.with_raw_response.cancel( |
| 238 |
dream_id="dream_id", |
| 239 |
) |
| 240 |
|
| 241 |
assert response.is_closed is True |
| 242 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 243 |
dream = response.parse() |
| 244 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 245 |
|
| 246 |
@parametrize |
| 247 |
def test_streaming_response_cancel(self, client: Anthropic) -> None: |
| 248 |
with client.beta.dreams.with_streaming_response.cancel( |
| 249 |
dream_id="dream_id", |
| 250 |
) as response: |
| 251 |
assert not response.is_closed |
| 252 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 253 |
|
| 254 |
dream = response.parse() |
| 255 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 256 |
|
| 257 |
assert cast(Any, response.is_closed) is True |
| 258 |
|
| 259 |
@parametrize |
| 260 |
def test_path_params_cancel(self, client: Anthropic) -> None: |
| 261 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `dream_id` but received ''"): |
| 262 |
client.beta.dreams.with_raw_response.cancel( |
| 263 |
dream_id="", |
| 264 |
) |
| 265 |
|
| 266 |
|
| 267 |
class TestAsyncDreams: |
| 268 |
parametrize = pytest.mark.parametrize( |
| 269 |
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] |
| 270 |
) |
| 271 |
|
| 272 |
@parametrize |
| 273 |
async def test_method_create(self, async_client: AsyncAnthropic) -> None: |
| 274 |
dream = await async_client.beta.dreams.create( |
| 275 |
inputs=[ |
| 276 |
{ |
| 277 |
"memory_store_id": "x", |
| 278 |
"type": "memory_store", |
| 279 |
} |
| 280 |
], |
| 281 |
model="string", |
| 282 |
) |
| 283 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 284 |
|
| 285 |
@parametrize |
| 286 |
async def test_method_create_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 287 |
dream = await async_client.beta.dreams.create( |
| 288 |
inputs=[ |
| 289 |
{ |
| 290 |
"memory_store_id": "x", |
| 291 |
"type": "memory_store", |
| 292 |
} |
| 293 |
], |
| 294 |
model="string", |
| 295 |
instructions="x", |
| 296 |
output_behavior={"type": "create_new"}, |
| 297 |
betas=["message-batches-2024-09-24"], |
| 298 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 299 |
) |
| 300 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 301 |
|
| 302 |
@parametrize |
| 303 |
async def test_raw_response_create(self, async_client: AsyncAnthropic) -> None: |
| 304 |
response = await async_client.beta.dreams.with_raw_response.create( |
| 305 |
inputs=[ |
| 306 |
{ |
| 307 |
"memory_store_id": "x", |
| 308 |
"type": "memory_store", |
| 309 |
} |
| 310 |
], |
| 311 |
model="string", |
| 312 |
) |
| 313 |
|
| 314 |
assert response.is_closed is True |
| 315 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 316 |
dream = await response.parse() |
| 317 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 318 |
|
| 319 |
@parametrize |
| 320 |
async def test_streaming_response_create(self, async_client: AsyncAnthropic) -> None: |
| 321 |
async with async_client.beta.dreams.with_streaming_response.create( |
| 322 |
inputs=[ |
| 323 |
{ |
| 324 |
"memory_store_id": "x", |
| 325 |
"type": "memory_store", |
| 326 |
} |
| 327 |
], |
| 328 |
model="string", |
| 329 |
) as response: |
| 330 |
assert not response.is_closed |
| 331 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 332 |
|
| 333 |
dream = await response.parse() |
| 334 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 335 |
|
| 336 |
assert cast(Any, response.is_closed) is True |
| 337 |
|
| 338 |
@parametrize |
| 339 |
async def test_method_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 340 |
dream = await async_client.beta.dreams.retrieve( |
| 341 |
dream_id="dream_id", |
| 342 |
) |
| 343 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 344 |
|
| 345 |
@parametrize |
| 346 |
async def test_method_retrieve_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 347 |
dream = await async_client.beta.dreams.retrieve( |
| 348 |
dream_id="dream_id", |
| 349 |
betas=["message-batches-2024-09-24"], |
| 350 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 351 |
) |
| 352 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 353 |
|
| 354 |
@parametrize |
| 355 |
async def test_raw_response_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 356 |
response = await async_client.beta.dreams.with_raw_response.retrieve( |
| 357 |
dream_id="dream_id", |
| 358 |
) |
| 359 |
|
| 360 |
assert response.is_closed is True |
| 361 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 362 |
dream = await response.parse() |
| 363 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 364 |
|
| 365 |
@parametrize |
| 366 |
async def test_streaming_response_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 367 |
async with async_client.beta.dreams.with_streaming_response.retrieve( |
| 368 |
dream_id="dream_id", |
| 369 |
) as response: |
| 370 |
assert not response.is_closed |
| 371 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 372 |
|
| 373 |
dream = await response.parse() |
| 374 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 375 |
|
| 376 |
assert cast(Any, response.is_closed) is True |
| 377 |
|
| 378 |
@parametrize |
| 379 |
async def test_path_params_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 380 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `dream_id` but received ''"): |
| 381 |
await async_client.beta.dreams.with_raw_response.retrieve( |
| 382 |
dream_id="", |
| 383 |
) |
| 384 |
|
| 385 |
@parametrize |
| 386 |
async def test_method_list(self, async_client: AsyncAnthropic) -> None: |
| 387 |
dream = await async_client.beta.dreams.list() |
| 388 |
assert_matches_type(AsyncPageCursor[BetaDream], dream, path=["response"]) |
| 389 |
|
| 390 |
@parametrize |
| 391 |
async def test_method_list_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 392 |
dream = await async_client.beta.dreams.list( |
| 393 |
created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 394 |
created_at_lt=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 395 |
include_archived=True, |
| 396 |
limit=0, |
| 397 |
page="page", |
| 398 |
statuses=["pending"], |
| 399 |
betas=["message-batches-2024-09-24"], |
| 400 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 401 |
) |
| 402 |
assert_matches_type(AsyncPageCursor[BetaDream], dream, path=["response"]) |
| 403 |
|
| 404 |
@parametrize |
| 405 |
async def test_raw_response_list(self, async_client: AsyncAnthropic) -> None: |
| 406 |
response = await async_client.beta.dreams.with_raw_response.list() |
| 407 |
|
| 408 |
assert response.is_closed is True |
| 409 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 410 |
dream = await response.parse() |
| 411 |
assert_matches_type(AsyncPageCursor[BetaDream], dream, path=["response"]) |
| 412 |
|
| 413 |
@parametrize |
| 414 |
async def test_streaming_response_list(self, async_client: AsyncAnthropic) -> None: |
| 415 |
async with async_client.beta.dreams.with_streaming_response.list() as response: |
| 416 |
assert not response.is_closed |
| 417 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 418 |
|
| 419 |
dream = await response.parse() |
| 420 |
assert_matches_type(AsyncPageCursor[BetaDream], dream, path=["response"]) |
| 421 |
|
| 422 |
assert cast(Any, response.is_closed) is True |
| 423 |
|
| 424 |
@parametrize |
| 425 |
async def test_method_archive(self, async_client: AsyncAnthropic) -> None: |
| 426 |
dream = await async_client.beta.dreams.archive( |
| 427 |
dream_id="dream_id", |
| 428 |
) |
| 429 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 430 |
|
| 431 |
@parametrize |
| 432 |
async def test_method_archive_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 433 |
dream = await async_client.beta.dreams.archive( |
| 434 |
dream_id="dream_id", |
| 435 |
betas=["message-batches-2024-09-24"], |
| 436 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 437 |
) |
| 438 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 439 |
|
| 440 |
@parametrize |
| 441 |
async def test_raw_response_archive(self, async_client: AsyncAnthropic) -> None: |
| 442 |
response = await async_client.beta.dreams.with_raw_response.archive( |
| 443 |
dream_id="dream_id", |
| 444 |
) |
| 445 |
|
| 446 |
assert response.is_closed is True |
| 447 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 448 |
dream = await response.parse() |
| 449 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 450 |
|
| 451 |
@parametrize |
| 452 |
async def test_streaming_response_archive(self, async_client: AsyncAnthropic) -> None: |
| 453 |
async with async_client.beta.dreams.with_streaming_response.archive( |
| 454 |
dream_id="dream_id", |
| 455 |
) as response: |
| 456 |
assert not response.is_closed |
| 457 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 458 |
|
| 459 |
dream = await response.parse() |
| 460 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 461 |
|
| 462 |
assert cast(Any, response.is_closed) is True |
| 463 |
|
| 464 |
@parametrize |
| 465 |
async def test_path_params_archive(self, async_client: AsyncAnthropic) -> None: |
| 466 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `dream_id` but received ''"): |
| 467 |
await async_client.beta.dreams.with_raw_response.archive( |
| 468 |
dream_id="", |
| 469 |
) |
| 470 |
|
| 471 |
@parametrize |
| 472 |
async def test_method_cancel(self, async_client: AsyncAnthropic) -> None: |
| 473 |
dream = await async_client.beta.dreams.cancel( |
| 474 |
dream_id="dream_id", |
| 475 |
) |
| 476 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 477 |
|
| 478 |
@parametrize |
| 479 |
async def test_method_cancel_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 480 |
dream = await async_client.beta.dreams.cancel( |
| 481 |
dream_id="dream_id", |
| 482 |
betas=["message-batches-2024-09-24"], |
| 483 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 484 |
) |
| 485 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 486 |
|
| 487 |
@parametrize |
| 488 |
async def test_raw_response_cancel(self, async_client: AsyncAnthropic) -> None: |
| 489 |
response = await async_client.beta.dreams.with_raw_response.cancel( |
| 490 |
dream_id="dream_id", |
| 491 |
) |
| 492 |
|
| 493 |
assert response.is_closed is True |
| 494 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 495 |
dream = await response.parse() |
| 496 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 497 |
|
| 498 |
@parametrize |
| 499 |
async def test_streaming_response_cancel(self, async_client: AsyncAnthropic) -> None: |
| 500 |
async with async_client.beta.dreams.with_streaming_response.cancel( |
| 501 |
dream_id="dream_id", |
| 502 |
) as response: |
| 503 |
assert not response.is_closed |
| 504 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 505 |
|
| 506 |
dream = await response.parse() |
| 507 |
assert_matches_type(BetaDream, dream, path=["response"]) |
| 508 |
|
| 509 |
assert cast(Any, response.is_closed) is True |
| 510 |
|
| 511 |
@parametrize |
| 512 |
async def test_path_params_cancel(self, async_client: AsyncAnthropic) -> None: |
| 513 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `dream_id` but received ''"): |
| 514 |
await async_client.beta.dreams.with_raw_response.cancel( |
| 515 |
dream_id="", |
| 516 |
) |