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