| 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 ( |
| 13 |
BetaManagedAgentsDeployment, |
| 14 |
BetaManagedAgentsDeploymentRun, |
| 15 |
) |
| 16 |
|
| 17 |
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") |
| 18 |
|
| 19 |
|
| 20 |
class TestDeployments: |
| 21 |
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) |
| 22 |
|
| 23 |
@parametrize |
| 24 |
def test_method_create(self, client: Anthropic) -> None: |
| 25 |
deployment = client.beta.deployments.create( |
| 26 |
agent="string", |
| 27 |
environment_id="x", |
| 28 |
initial_events=[ |
| 29 |
{ |
| 30 |
"content": [ |
| 31 |
{ |
| 32 |
"text": "Where is my order #1234?", |
| 33 |
"type": "text", |
| 34 |
} |
| 35 |
], |
| 36 |
"type": "user.message", |
| 37 |
} |
| 38 |
], |
| 39 |
name="x", |
| 40 |
) |
| 41 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 42 |
|
| 43 |
@parametrize |
| 44 |
def test_method_create_with_all_params(self, client: Anthropic) -> None: |
| 45 |
deployment = client.beta.deployments.create( |
| 46 |
agent="string", |
| 47 |
environment_id="x", |
| 48 |
initial_events=[ |
| 49 |
{ |
| 50 |
"content": [ |
| 51 |
{ |
| 52 |
"text": "Where is my order #1234?", |
| 53 |
"type": "text", |
| 54 |
} |
| 55 |
], |
| 56 |
"type": "user.message", |
| 57 |
} |
| 58 |
], |
| 59 |
name="x", |
| 60 |
budget={ |
| 61 |
"max_list_cost": { |
| 62 |
"amount": "2500", |
| 63 |
"currency": "USD", |
| 64 |
}, |
| 65 |
"type": "limit", |
| 66 |
}, |
| 67 |
description="description", |
| 68 |
metadata={"foo": "string"}, |
| 69 |
resources=[ |
| 70 |
{ |
| 71 |
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w", |
| 72 |
"type": "file", |
| 73 |
"mount_path": "/uploads/receipt.pdf", |
| 74 |
} |
| 75 |
], |
| 76 |
schedule={ |
| 77 |
"expression": "0 9 * * 1-5", |
| 78 |
"timezone": "America/Los_Angeles", |
| 79 |
"type": "cron", |
| 80 |
}, |
| 81 |
vault_ids=["string"], |
| 82 |
betas=["message-batches-2024-09-24"], |
| 83 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 84 |
) |
| 85 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 86 |
|
| 87 |
@parametrize |
| 88 |
def test_raw_response_create(self, client: Anthropic) -> None: |
| 89 |
response = client.beta.deployments.with_raw_response.create( |
| 90 |
agent="string", |
| 91 |
environment_id="x", |
| 92 |
initial_events=[ |
| 93 |
{ |
| 94 |
"content": [ |
| 95 |
{ |
| 96 |
"text": "Where is my order #1234?", |
| 97 |
"type": "text", |
| 98 |
} |
| 99 |
], |
| 100 |
"type": "user.message", |
| 101 |
} |
| 102 |
], |
| 103 |
name="x", |
| 104 |
) |
| 105 |
|
| 106 |
assert response.is_closed is True |
| 107 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 108 |
deployment = response.parse() |
| 109 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 110 |
|
| 111 |
@parametrize |
| 112 |
def test_streaming_response_create(self, client: Anthropic) -> None: |
| 113 |
with client.beta.deployments.with_streaming_response.create( |
| 114 |
agent="string", |
| 115 |
environment_id="x", |
| 116 |
initial_events=[ |
| 117 |
{ |
| 118 |
"content": [ |
| 119 |
{ |
| 120 |
"text": "Where is my order #1234?", |
| 121 |
"type": "text", |
| 122 |
} |
| 123 |
], |
| 124 |
"type": "user.message", |
| 125 |
} |
| 126 |
], |
| 127 |
name="x", |
| 128 |
) as response: |
| 129 |
assert not response.is_closed |
| 130 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 131 |
|
| 132 |
deployment = response.parse() |
| 133 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 134 |
|
| 135 |
assert cast(Any, response.is_closed) is True |
| 136 |
|
| 137 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 138 |
@parametrize |
| 139 |
def test_method_retrieve(self, client: Anthropic) -> None: |
| 140 |
deployment = client.beta.deployments.retrieve( |
| 141 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 142 |
) |
| 143 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 144 |
|
| 145 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 146 |
@parametrize |
| 147 |
def test_method_retrieve_with_all_params(self, client: Anthropic) -> None: |
| 148 |
deployment = client.beta.deployments.retrieve( |
| 149 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 150 |
betas=["message-batches-2024-09-24"], |
| 151 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 152 |
) |
| 153 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 154 |
|
| 155 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 156 |
@parametrize |
| 157 |
def test_raw_response_retrieve(self, client: Anthropic) -> None: |
| 158 |
response = client.beta.deployments.with_raw_response.retrieve( |
| 159 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 160 |
) |
| 161 |
|
| 162 |
assert response.is_closed is True |
| 163 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 164 |
deployment = response.parse() |
| 165 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 166 |
|
| 167 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 168 |
@parametrize |
| 169 |
def test_streaming_response_retrieve(self, client: Anthropic) -> None: |
| 170 |
with client.beta.deployments.with_streaming_response.retrieve( |
| 171 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 172 |
) as response: |
| 173 |
assert not response.is_closed |
| 174 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 175 |
|
| 176 |
deployment = response.parse() |
| 177 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 178 |
|
| 179 |
assert cast(Any, response.is_closed) is True |
| 180 |
|
| 181 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 182 |
@parametrize |
| 183 |
def test_path_params_retrieve(self, client: Anthropic) -> None: |
| 184 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 185 |
client.beta.deployments.with_raw_response.retrieve( |
| 186 |
deployment_id="", |
| 187 |
) |
| 188 |
|
| 189 |
@parametrize |
| 190 |
def test_method_update(self, client: Anthropic) -> None: |
| 191 |
deployment = client.beta.deployments.update( |
| 192 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 193 |
) |
| 194 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 195 |
|
| 196 |
@parametrize |
| 197 |
def test_method_update_with_all_params(self, client: Anthropic) -> None: |
| 198 |
deployment = client.beta.deployments.update( |
| 199 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 200 |
agent="string", |
| 201 |
budget={ |
| 202 |
"max_list_cost": { |
| 203 |
"amount": "2500", |
| 204 |
"currency": "USD", |
| 205 |
}, |
| 206 |
"type": "limit", |
| 207 |
}, |
| 208 |
description="description", |
| 209 |
environment_id="environment_id", |
| 210 |
initial_events=[ |
| 211 |
{ |
| 212 |
"content": [ |
| 213 |
{ |
| 214 |
"text": "Where is my order #1234?", |
| 215 |
"type": "text", |
| 216 |
} |
| 217 |
], |
| 218 |
"type": "user.message", |
| 219 |
} |
| 220 |
], |
| 221 |
metadata={"foo": "string"}, |
| 222 |
name="name", |
| 223 |
resources=[ |
| 224 |
{ |
| 225 |
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w", |
| 226 |
"type": "file", |
| 227 |
"mount_path": "/uploads/receipt.pdf", |
| 228 |
} |
| 229 |
], |
| 230 |
schedule={ |
| 231 |
"expression": "0 9 * * 1-5", |
| 232 |
"timezone": "America/Los_Angeles", |
| 233 |
"type": "cron", |
| 234 |
}, |
| 235 |
vault_ids=["string"], |
| 236 |
betas=["message-batches-2024-09-24"], |
| 237 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 238 |
) |
| 239 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 240 |
|
| 241 |
@parametrize |
| 242 |
def test_raw_response_update(self, client: Anthropic) -> None: |
| 243 |
response = client.beta.deployments.with_raw_response.update( |
| 244 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 245 |
) |
| 246 |
|
| 247 |
assert response.is_closed is True |
| 248 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 249 |
deployment = response.parse() |
| 250 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 251 |
|
| 252 |
@parametrize |
| 253 |
def test_streaming_response_update(self, client: Anthropic) -> None: |
| 254 |
with client.beta.deployments.with_streaming_response.update( |
| 255 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 256 |
) as response: |
| 257 |
assert not response.is_closed |
| 258 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 259 |
|
| 260 |
deployment = response.parse() |
| 261 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 262 |
|
| 263 |
assert cast(Any, response.is_closed) is True |
| 264 |
|
| 265 |
@parametrize |
| 266 |
def test_path_params_update(self, client: Anthropic) -> None: |
| 267 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 268 |
client.beta.deployments.with_raw_response.update( |
| 269 |
deployment_id="", |
| 270 |
) |
| 271 |
|
| 272 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 273 |
@parametrize |
| 274 |
def test_method_list(self, client: Anthropic) -> None: |
| 275 |
deployment = client.beta.deployments.list() |
| 276 |
assert_matches_type(SyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 277 |
|
| 278 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 279 |
@parametrize |
| 280 |
def test_method_list_with_all_params(self, client: Anthropic) -> None: |
| 281 |
deployment = client.beta.deployments.list( |
| 282 |
agent_id="agent_id", |
| 283 |
created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 284 |
created_at_lte=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 285 |
include_archived=True, |
| 286 |
limit=0, |
| 287 |
page="page", |
| 288 |
status="active", |
| 289 |
betas=["message-batches-2024-09-24"], |
| 290 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 291 |
) |
| 292 |
assert_matches_type(SyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 293 |
|
| 294 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 295 |
@parametrize |
| 296 |
def test_raw_response_list(self, client: Anthropic) -> None: |
| 297 |
response = client.beta.deployments.with_raw_response.list() |
| 298 |
|
| 299 |
assert response.is_closed is True |
| 300 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 301 |
deployment = response.parse() |
| 302 |
assert_matches_type(SyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 303 |
|
| 304 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 305 |
@parametrize |
| 306 |
def test_streaming_response_list(self, client: Anthropic) -> None: |
| 307 |
with client.beta.deployments.with_streaming_response.list() as response: |
| 308 |
assert not response.is_closed |
| 309 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 310 |
|
| 311 |
deployment = response.parse() |
| 312 |
assert_matches_type(SyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 313 |
|
| 314 |
assert cast(Any, response.is_closed) is True |
| 315 |
|
| 316 |
@parametrize |
| 317 |
def test_method_archive(self, client: Anthropic) -> None: |
| 318 |
deployment = client.beta.deployments.archive( |
| 319 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 320 |
) |
| 321 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 322 |
|
| 323 |
@parametrize |
| 324 |
def test_method_archive_with_all_params(self, client: Anthropic) -> None: |
| 325 |
deployment = client.beta.deployments.archive( |
| 326 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 327 |
betas=["message-batches-2024-09-24"], |
| 328 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 329 |
) |
| 330 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 331 |
|
| 332 |
@parametrize |
| 333 |
def test_raw_response_archive(self, client: Anthropic) -> None: |
| 334 |
response = client.beta.deployments.with_raw_response.archive( |
| 335 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 336 |
) |
| 337 |
|
| 338 |
assert response.is_closed is True |
| 339 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 340 |
deployment = response.parse() |
| 341 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 342 |
|
| 343 |
@parametrize |
| 344 |
def test_streaming_response_archive(self, client: Anthropic) -> None: |
| 345 |
with client.beta.deployments.with_streaming_response.archive( |
| 346 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 347 |
) as response: |
| 348 |
assert not response.is_closed |
| 349 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 350 |
|
| 351 |
deployment = response.parse() |
| 352 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 353 |
|
| 354 |
assert cast(Any, response.is_closed) is True |
| 355 |
|
| 356 |
@parametrize |
| 357 |
def test_path_params_archive(self, client: Anthropic) -> None: |
| 358 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 359 |
client.beta.deployments.with_raw_response.archive( |
| 360 |
deployment_id="", |
| 361 |
) |
| 362 |
|
| 363 |
@parametrize |
| 364 |
def test_method_pause(self, client: Anthropic) -> None: |
| 365 |
deployment = client.beta.deployments.pause( |
| 366 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 367 |
) |
| 368 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 369 |
|
| 370 |
@parametrize |
| 371 |
def test_method_pause_with_all_params(self, client: Anthropic) -> None: |
| 372 |
deployment = client.beta.deployments.pause( |
| 373 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 374 |
betas=["message-batches-2024-09-24"], |
| 375 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 376 |
) |
| 377 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 378 |
|
| 379 |
@parametrize |
| 380 |
def test_raw_response_pause(self, client: Anthropic) -> None: |
| 381 |
response = client.beta.deployments.with_raw_response.pause( |
| 382 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 383 |
) |
| 384 |
|
| 385 |
assert response.is_closed is True |
| 386 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 387 |
deployment = response.parse() |
| 388 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 389 |
|
| 390 |
@parametrize |
| 391 |
def test_streaming_response_pause(self, client: Anthropic) -> None: |
| 392 |
with client.beta.deployments.with_streaming_response.pause( |
| 393 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 394 |
) as response: |
| 395 |
assert not response.is_closed |
| 396 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 397 |
|
| 398 |
deployment = response.parse() |
| 399 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 400 |
|
| 401 |
assert cast(Any, response.is_closed) is True |
| 402 |
|
| 403 |
@parametrize |
| 404 |
def test_path_params_pause(self, client: Anthropic) -> None: |
| 405 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 406 |
client.beta.deployments.with_raw_response.pause( |
| 407 |
deployment_id="", |
| 408 |
) |
| 409 |
|
| 410 |
@parametrize |
| 411 |
def test_method_run(self, client: Anthropic) -> None: |
| 412 |
deployment = client.beta.deployments.run( |
| 413 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 414 |
) |
| 415 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 416 |
|
| 417 |
@parametrize |
| 418 |
def test_method_run_with_all_params(self, client: Anthropic) -> None: |
| 419 |
deployment = client.beta.deployments.run( |
| 420 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 421 |
betas=["message-batches-2024-09-24"], |
| 422 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 423 |
) |
| 424 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 425 |
|
| 426 |
@parametrize |
| 427 |
def test_raw_response_run(self, client: Anthropic) -> None: |
| 428 |
response = client.beta.deployments.with_raw_response.run( |
| 429 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 430 |
) |
| 431 |
|
| 432 |
assert response.is_closed is True |
| 433 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 434 |
deployment = response.parse() |
| 435 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 436 |
|
| 437 |
@parametrize |
| 438 |
def test_streaming_response_run(self, client: Anthropic) -> None: |
| 439 |
with client.beta.deployments.with_streaming_response.run( |
| 440 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 441 |
) as response: |
| 442 |
assert not response.is_closed |
| 443 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 444 |
|
| 445 |
deployment = response.parse() |
| 446 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 447 |
|
| 448 |
assert cast(Any, response.is_closed) is True |
| 449 |
|
| 450 |
@parametrize |
| 451 |
def test_path_params_run(self, client: Anthropic) -> None: |
| 452 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 453 |
client.beta.deployments.with_raw_response.run( |
| 454 |
deployment_id="", |
| 455 |
) |
| 456 |
|
| 457 |
@parametrize |
| 458 |
def test_method_unpause(self, client: Anthropic) -> None: |
| 459 |
deployment = client.beta.deployments.unpause( |
| 460 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 461 |
) |
| 462 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 463 |
|
| 464 |
@parametrize |
| 465 |
def test_method_unpause_with_all_params(self, client: Anthropic) -> None: |
| 466 |
deployment = client.beta.deployments.unpause( |
| 467 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 468 |
betas=["message-batches-2024-09-24"], |
| 469 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 470 |
) |
| 471 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 472 |
|
| 473 |
@parametrize |
| 474 |
def test_raw_response_unpause(self, client: Anthropic) -> None: |
| 475 |
response = client.beta.deployments.with_raw_response.unpause( |
| 476 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 477 |
) |
| 478 |
|
| 479 |
assert response.is_closed is True |
| 480 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 481 |
deployment = response.parse() |
| 482 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 483 |
|
| 484 |
@parametrize |
| 485 |
def test_streaming_response_unpause(self, client: Anthropic) -> None: |
| 486 |
with client.beta.deployments.with_streaming_response.unpause( |
| 487 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 488 |
) as response: |
| 489 |
assert not response.is_closed |
| 490 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 491 |
|
| 492 |
deployment = response.parse() |
| 493 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 494 |
|
| 495 |
assert cast(Any, response.is_closed) is True |
| 496 |
|
| 497 |
@parametrize |
| 498 |
def test_path_params_unpause(self, client: Anthropic) -> None: |
| 499 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 500 |
client.beta.deployments.with_raw_response.unpause( |
| 501 |
deployment_id="", |
| 502 |
) |
| 503 |
|
| 504 |
|
| 505 |
class TestAsyncDeployments: |
| 506 |
parametrize = pytest.mark.parametrize( |
| 507 |
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] |
| 508 |
) |
| 509 |
|
| 510 |
@parametrize |
| 511 |
async def test_method_create(self, async_client: AsyncAnthropic) -> None: |
| 512 |
deployment = await async_client.beta.deployments.create( |
| 513 |
agent="string", |
| 514 |
environment_id="x", |
| 515 |
initial_events=[ |
| 516 |
{ |
| 517 |
"content": [ |
| 518 |
{ |
| 519 |
"text": "Where is my order #1234?", |
| 520 |
"type": "text", |
| 521 |
} |
| 522 |
], |
| 523 |
"type": "user.message", |
| 524 |
} |
| 525 |
], |
| 526 |
name="x", |
| 527 |
) |
| 528 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 529 |
|
| 530 |
@parametrize |
| 531 |
async def test_method_create_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 532 |
deployment = await async_client.beta.deployments.create( |
| 533 |
agent="string", |
| 534 |
environment_id="x", |
| 535 |
initial_events=[ |
| 536 |
{ |
| 537 |
"content": [ |
| 538 |
{ |
| 539 |
"text": "Where is my order #1234?", |
| 540 |
"type": "text", |
| 541 |
} |
| 542 |
], |
| 543 |
"type": "user.message", |
| 544 |
} |
| 545 |
], |
| 546 |
name="x", |
| 547 |
budget={ |
| 548 |
"max_list_cost": { |
| 549 |
"amount": "2500", |
| 550 |
"currency": "USD", |
| 551 |
}, |
| 552 |
"type": "limit", |
| 553 |
}, |
| 554 |
description="description", |
| 555 |
metadata={"foo": "string"}, |
| 556 |
resources=[ |
| 557 |
{ |
| 558 |
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w", |
| 559 |
"type": "file", |
| 560 |
"mount_path": "/uploads/receipt.pdf", |
| 561 |
} |
| 562 |
], |
| 563 |
schedule={ |
| 564 |
"expression": "0 9 * * 1-5", |
| 565 |
"timezone": "America/Los_Angeles", |
| 566 |
"type": "cron", |
| 567 |
}, |
| 568 |
vault_ids=["string"], |
| 569 |
betas=["message-batches-2024-09-24"], |
| 570 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 571 |
) |
| 572 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 573 |
|
| 574 |
@parametrize |
| 575 |
async def test_raw_response_create(self, async_client: AsyncAnthropic) -> None: |
| 576 |
response = await async_client.beta.deployments.with_raw_response.create( |
| 577 |
agent="string", |
| 578 |
environment_id="x", |
| 579 |
initial_events=[ |
| 580 |
{ |
| 581 |
"content": [ |
| 582 |
{ |
| 583 |
"text": "Where is my order #1234?", |
| 584 |
"type": "text", |
| 585 |
} |
| 586 |
], |
| 587 |
"type": "user.message", |
| 588 |
} |
| 589 |
], |
| 590 |
name="x", |
| 591 |
) |
| 592 |
|
| 593 |
assert response.is_closed is True |
| 594 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 595 |
deployment = await response.parse() |
| 596 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 597 |
|
| 598 |
@parametrize |
| 599 |
async def test_streaming_response_create(self, async_client: AsyncAnthropic) -> None: |
| 600 |
async with async_client.beta.deployments.with_streaming_response.create( |
| 601 |
agent="string", |
| 602 |
environment_id="x", |
| 603 |
initial_events=[ |
| 604 |
{ |
| 605 |
"content": [ |
| 606 |
{ |
| 607 |
"text": "Where is my order #1234?", |
| 608 |
"type": "text", |
| 609 |
} |
| 610 |
], |
| 611 |
"type": "user.message", |
| 612 |
} |
| 613 |
], |
| 614 |
name="x", |
| 615 |
) as response: |
| 616 |
assert not response.is_closed |
| 617 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 618 |
|
| 619 |
deployment = await response.parse() |
| 620 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 621 |
|
| 622 |
assert cast(Any, response.is_closed) is True |
| 623 |
|
| 624 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 625 |
@parametrize |
| 626 |
async def test_method_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 627 |
deployment = await async_client.beta.deployments.retrieve( |
| 628 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 629 |
) |
| 630 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 631 |
|
| 632 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 633 |
@parametrize |
| 634 |
async def test_method_retrieve_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 635 |
deployment = await async_client.beta.deployments.retrieve( |
| 636 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 637 |
betas=["message-batches-2024-09-24"], |
| 638 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 639 |
) |
| 640 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 641 |
|
| 642 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 643 |
@parametrize |
| 644 |
async def test_raw_response_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 645 |
response = await async_client.beta.deployments.with_raw_response.retrieve( |
| 646 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 647 |
) |
| 648 |
|
| 649 |
assert response.is_closed is True |
| 650 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 651 |
deployment = await response.parse() |
| 652 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 653 |
|
| 654 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 655 |
@parametrize |
| 656 |
async def test_streaming_response_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 657 |
async with async_client.beta.deployments.with_streaming_response.retrieve( |
| 658 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 659 |
) as response: |
| 660 |
assert not response.is_closed |
| 661 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 662 |
|
| 663 |
deployment = await response.parse() |
| 664 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 665 |
|
| 666 |
assert cast(Any, response.is_closed) is True |
| 667 |
|
| 668 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 669 |
@parametrize |
| 670 |
async def test_path_params_retrieve(self, async_client: AsyncAnthropic) -> None: |
| 671 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 672 |
await async_client.beta.deployments.with_raw_response.retrieve( |
| 673 |
deployment_id="", |
| 674 |
) |
| 675 |
|
| 676 |
@parametrize |
| 677 |
async def test_method_update(self, async_client: AsyncAnthropic) -> None: |
| 678 |
deployment = await async_client.beta.deployments.update( |
| 679 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 680 |
) |
| 681 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 682 |
|
| 683 |
@parametrize |
| 684 |
async def test_method_update_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 685 |
deployment = await async_client.beta.deployments.update( |
| 686 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 687 |
agent="string", |
| 688 |
budget={ |
| 689 |
"max_list_cost": { |
| 690 |
"amount": "2500", |
| 691 |
"currency": "USD", |
| 692 |
}, |
| 693 |
"type": "limit", |
| 694 |
}, |
| 695 |
description="description", |
| 696 |
environment_id="environment_id", |
| 697 |
initial_events=[ |
| 698 |
{ |
| 699 |
"content": [ |
| 700 |
{ |
| 701 |
"text": "Where is my order #1234?", |
| 702 |
"type": "text", |
| 703 |
} |
| 704 |
], |
| 705 |
"type": "user.message", |
| 706 |
} |
| 707 |
], |
| 708 |
metadata={"foo": "string"}, |
| 709 |
name="name", |
| 710 |
resources=[ |
| 711 |
{ |
| 712 |
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w", |
| 713 |
"type": "file", |
| 714 |
"mount_path": "/uploads/receipt.pdf", |
| 715 |
} |
| 716 |
], |
| 717 |
schedule={ |
| 718 |
"expression": "0 9 * * 1-5", |
| 719 |
"timezone": "America/Los_Angeles", |
| 720 |
"type": "cron", |
| 721 |
}, |
| 722 |
vault_ids=["string"], |
| 723 |
betas=["message-batches-2024-09-24"], |
| 724 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 725 |
) |
| 726 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 727 |
|
| 728 |
@parametrize |
| 729 |
async def test_raw_response_update(self, async_client: AsyncAnthropic) -> None: |
| 730 |
response = await async_client.beta.deployments.with_raw_response.update( |
| 731 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 732 |
) |
| 733 |
|
| 734 |
assert response.is_closed is True |
| 735 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 736 |
deployment = await response.parse() |
| 737 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 738 |
|
| 739 |
@parametrize |
| 740 |
async def test_streaming_response_update(self, async_client: AsyncAnthropic) -> None: |
| 741 |
async with async_client.beta.deployments.with_streaming_response.update( |
| 742 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 743 |
) as response: |
| 744 |
assert not response.is_closed |
| 745 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 746 |
|
| 747 |
deployment = await response.parse() |
| 748 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 749 |
|
| 750 |
assert cast(Any, response.is_closed) is True |
| 751 |
|
| 752 |
@parametrize |
| 753 |
async def test_path_params_update(self, async_client: AsyncAnthropic) -> None: |
| 754 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 755 |
await async_client.beta.deployments.with_raw_response.update( |
| 756 |
deployment_id="", |
| 757 |
) |
| 758 |
|
| 759 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 760 |
@parametrize |
| 761 |
async def test_method_list(self, async_client: AsyncAnthropic) -> None: |
| 762 |
deployment = await async_client.beta.deployments.list() |
| 763 |
assert_matches_type(AsyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 764 |
|
| 765 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 766 |
@parametrize |
| 767 |
async def test_method_list_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 768 |
deployment = await async_client.beta.deployments.list( |
| 769 |
agent_id="agent_id", |
| 770 |
created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 771 |
created_at_lte=parse_datetime("2019-12-27T18:11:19.117Z"), |
| 772 |
include_archived=True, |
| 773 |
limit=0, |
| 774 |
page="page", |
| 775 |
status="active", |
| 776 |
betas=["message-batches-2024-09-24"], |
| 777 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 778 |
) |
| 779 |
assert_matches_type(AsyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 780 |
|
| 781 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 782 |
@parametrize |
| 783 |
async def test_raw_response_list(self, async_client: AsyncAnthropic) -> None: |
| 784 |
response = await async_client.beta.deployments.with_raw_response.list() |
| 785 |
|
| 786 |
assert response.is_closed is True |
| 787 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 788 |
deployment = await response.parse() |
| 789 |
assert_matches_type(AsyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 790 |
|
| 791 |
@pytest.mark.skip(reason="buildURL drops path-level query params") |
| 792 |
@parametrize |
| 793 |
async def test_streaming_response_list(self, async_client: AsyncAnthropic) -> None: |
| 794 |
async with async_client.beta.deployments.with_streaming_response.list() as response: |
| 795 |
assert not response.is_closed |
| 796 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 797 |
|
| 798 |
deployment = await response.parse() |
| 799 |
assert_matches_type(AsyncPageCursor[BetaManagedAgentsDeployment], deployment, path=["response"]) |
| 800 |
|
| 801 |
assert cast(Any, response.is_closed) is True |
| 802 |
|
| 803 |
@parametrize |
| 804 |
async def test_method_archive(self, async_client: AsyncAnthropic) -> None: |
| 805 |
deployment = await async_client.beta.deployments.archive( |
| 806 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 807 |
) |
| 808 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 809 |
|
| 810 |
@parametrize |
| 811 |
async def test_method_archive_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 812 |
deployment = await async_client.beta.deployments.archive( |
| 813 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 814 |
betas=["message-batches-2024-09-24"], |
| 815 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 816 |
) |
| 817 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 818 |
|
| 819 |
@parametrize |
| 820 |
async def test_raw_response_archive(self, async_client: AsyncAnthropic) -> None: |
| 821 |
response = await async_client.beta.deployments.with_raw_response.archive( |
| 822 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 823 |
) |
| 824 |
|
| 825 |
assert response.is_closed is True |
| 826 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 827 |
deployment = await response.parse() |
| 828 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 829 |
|
| 830 |
@parametrize |
| 831 |
async def test_streaming_response_archive(self, async_client: AsyncAnthropic) -> None: |
| 832 |
async with async_client.beta.deployments.with_streaming_response.archive( |
| 833 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 834 |
) as response: |
| 835 |
assert not response.is_closed |
| 836 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 837 |
|
| 838 |
deployment = await response.parse() |
| 839 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 840 |
|
| 841 |
assert cast(Any, response.is_closed) is True |
| 842 |
|
| 843 |
@parametrize |
| 844 |
async def test_path_params_archive(self, async_client: AsyncAnthropic) -> None: |
| 845 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 846 |
await async_client.beta.deployments.with_raw_response.archive( |
| 847 |
deployment_id="", |
| 848 |
) |
| 849 |
|
| 850 |
@parametrize |
| 851 |
async def test_method_pause(self, async_client: AsyncAnthropic) -> None: |
| 852 |
deployment = await async_client.beta.deployments.pause( |
| 853 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 854 |
) |
| 855 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 856 |
|
| 857 |
@parametrize |
| 858 |
async def test_method_pause_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 859 |
deployment = await async_client.beta.deployments.pause( |
| 860 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 861 |
betas=["message-batches-2024-09-24"], |
| 862 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 863 |
) |
| 864 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 865 |
|
| 866 |
@parametrize |
| 867 |
async def test_raw_response_pause(self, async_client: AsyncAnthropic) -> None: |
| 868 |
response = await async_client.beta.deployments.with_raw_response.pause( |
| 869 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 870 |
) |
| 871 |
|
| 872 |
assert response.is_closed is True |
| 873 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 874 |
deployment = await response.parse() |
| 875 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 876 |
|
| 877 |
@parametrize |
| 878 |
async def test_streaming_response_pause(self, async_client: AsyncAnthropic) -> None: |
| 879 |
async with async_client.beta.deployments.with_streaming_response.pause( |
| 880 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 881 |
) as response: |
| 882 |
assert not response.is_closed |
| 883 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 884 |
|
| 885 |
deployment = await response.parse() |
| 886 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 887 |
|
| 888 |
assert cast(Any, response.is_closed) is True |
| 889 |
|
| 890 |
@parametrize |
| 891 |
async def test_path_params_pause(self, async_client: AsyncAnthropic) -> None: |
| 892 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 893 |
await async_client.beta.deployments.with_raw_response.pause( |
| 894 |
deployment_id="", |
| 895 |
) |
| 896 |
|
| 897 |
@parametrize |
| 898 |
async def test_method_run(self, async_client: AsyncAnthropic) -> None: |
| 899 |
deployment = await async_client.beta.deployments.run( |
| 900 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 901 |
) |
| 902 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 903 |
|
| 904 |
@parametrize |
| 905 |
async def test_method_run_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 906 |
deployment = await async_client.beta.deployments.run( |
| 907 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 908 |
betas=["message-batches-2024-09-24"], |
| 909 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 910 |
) |
| 911 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 912 |
|
| 913 |
@parametrize |
| 914 |
async def test_raw_response_run(self, async_client: AsyncAnthropic) -> None: |
| 915 |
response = await async_client.beta.deployments.with_raw_response.run( |
| 916 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 917 |
) |
| 918 |
|
| 919 |
assert response.is_closed is True |
| 920 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 921 |
deployment = await response.parse() |
| 922 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 923 |
|
| 924 |
@parametrize |
| 925 |
async def test_streaming_response_run(self, async_client: AsyncAnthropic) -> None: |
| 926 |
async with async_client.beta.deployments.with_streaming_response.run( |
| 927 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 928 |
) as response: |
| 929 |
assert not response.is_closed |
| 930 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 931 |
|
| 932 |
deployment = await response.parse() |
| 933 |
assert_matches_type(BetaManagedAgentsDeploymentRun, deployment, path=["response"]) |
| 934 |
|
| 935 |
assert cast(Any, response.is_closed) is True |
| 936 |
|
| 937 |
@parametrize |
| 938 |
async def test_path_params_run(self, async_client: AsyncAnthropic) -> None: |
| 939 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 940 |
await async_client.beta.deployments.with_raw_response.run( |
| 941 |
deployment_id="", |
| 942 |
) |
| 943 |
|
| 944 |
@parametrize |
| 945 |
async def test_method_unpause(self, async_client: AsyncAnthropic) -> None: |
| 946 |
deployment = await async_client.beta.deployments.unpause( |
| 947 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 948 |
) |
| 949 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 950 |
|
| 951 |
@parametrize |
| 952 |
async def test_method_unpause_with_all_params(self, async_client: AsyncAnthropic) -> None: |
| 953 |
deployment = await async_client.beta.deployments.unpause( |
| 954 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 955 |
betas=["message-batches-2024-09-24"], |
| 956 |
workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy", |
| 957 |
) |
| 958 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 959 |
|
| 960 |
@parametrize |
| 961 |
async def test_raw_response_unpause(self, async_client: AsyncAnthropic) -> None: |
| 962 |
response = await async_client.beta.deployments.with_raw_response.unpause( |
| 963 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 964 |
) |
| 965 |
|
| 966 |
assert response.is_closed is True |
| 967 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 968 |
deployment = await response.parse() |
| 969 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 970 |
|
| 971 |
@parametrize |
| 972 |
async def test_streaming_response_unpause(self, async_client: AsyncAnthropic) -> None: |
| 973 |
async with async_client.beta.deployments.with_streaming_response.unpause( |
| 974 |
deployment_id="depl_011CZkZcDH3vPqd7xnEfwTai", |
| 975 |
) as response: |
| 976 |
assert not response.is_closed |
| 977 |
assert response.http_request.headers.get("X-Stainless-Lang") == "python" |
| 978 |
|
| 979 |
deployment = await response.parse() |
| 980 |
assert_matches_type(BetaManagedAgentsDeployment, deployment, path=["response"]) |
| 981 |
|
| 982 |
assert cast(Any, response.is_closed) is True |
| 983 |
|
| 984 |
@parametrize |
| 985 |
async def test_path_params_unpause(self, async_client: AsyncAnthropic) -> None: |
| 986 |
with pytest.raises(ValueError, match=r"Expected a non-empty value for `deployment_id` but received ''"): |
| 987 |
await async_client.beta.deployments.with_raw_response.unpause( |
| 988 |
deployment_id="", |
| 989 |
) |