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