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