openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
tests/api_resources/fine_tuning/checkpoints/test_permissions.py
438lines · modeblame
7e8b3171stainless-app[bot]1 years ago | 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 | |
0c14b4b9stainless-app[bot]4 months ago | 12 | from openai.pagination import SyncPage, AsyncPage, SyncConversationCursorPage, AsyncConversationCursorPage |
7e8b3171stainless-app[bot]1 years ago | 13 | from openai.types.fine_tuning.checkpoints import ( |
0c14b4b9stainless-app[bot]4 months ago | 14 | PermissionListResponse, |
7e8b3171stainless-app[bot]1 years ago | 15 | PermissionCreateResponse, |
| 16 | PermissionDeleteResponse, | |
| 17 | PermissionRetrieveResponse, | |
| 18 | ) | |
| 19 | | |
0c14b4b9stainless-app[bot]4 months ago | 20 | # pyright: reportDeprecated=false |
| 21 | | |
7e8b3171stainless-app[bot]1 years ago | 22 | base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") |
| 23 | | |
| 24 | | |
| 25 | class TestPermissions: | |
| 26 | parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) | |
| 27 | | |
| 28 | @parametrize | |
| 29 | def test_method_create(self, client: OpenAI) -> None: | |
| 30 | permission = client.fine_tuning.checkpoints.permissions.create( | |
| 31 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
| 32 | project_ids=["string"], | |
| 33 | ) | |
| 34 | assert_matches_type(SyncPage[PermissionCreateResponse], permission, path=["response"]) | |
| 35 | | |
| 36 | @parametrize | |
| 37 | def test_raw_response_create(self, client: OpenAI) -> None: | |
| 38 | response = client.fine_tuning.checkpoints.permissions.with_raw_response.create( | |
| 39 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
| 40 | project_ids=["string"], | |
| 41 | ) | |
| 42 | | |
| 43 | assert response.is_closed is True | |
| 44 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 45 | permission = response.parse() | |
| 46 | assert_matches_type(SyncPage[PermissionCreateResponse], permission, path=["response"]) | |
| 47 | | |
| 48 | @parametrize | |
| 49 | def test_streaming_response_create(self, client: OpenAI) -> None: | |
| 50 | with client.fine_tuning.checkpoints.permissions.with_streaming_response.create( | |
| 51 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
| 52 | project_ids=["string"], | |
| 53 | ) as response: | |
| 54 | assert not response.is_closed | |
| 55 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 56 | | |
| 57 | permission = response.parse() | |
| 58 | assert_matches_type(SyncPage[PermissionCreateResponse], permission, path=["response"]) | |
| 59 | | |
| 60 | assert cast(Any, response.is_closed) is True | |
| 61 | | |
| 62 | @parametrize | |
| 63 | def test_path_params_create(self, client: OpenAI) -> None: | |
| 64 | with pytest.raises( | |
| 65 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 66 | ): | |
| 67 | client.fine_tuning.checkpoints.permissions.with_raw_response.create( | |
| 68 | fine_tuned_model_checkpoint="", | |
| 69 | project_ids=["string"], | |
| 70 | ) | |
| 71 | | |
| 72 | @parametrize | |
| 73 | def test_method_retrieve(self, client: OpenAI) -> None: | |
0c14b4b9stainless-app[bot]4 months ago | 74 | with pytest.warns(DeprecationWarning): |
| 75 | permission = client.fine_tuning.checkpoints.permissions.retrieve( | |
| 76 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 77 | ) | |
| 78 | | |
8707913dstainless-app[bot]1 years ago | 79 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 80 | |
| 81 | @parametrize | |
| 82 | def test_method_retrieve_with_all_params(self, client: OpenAI) -> None: | |
0c14b4b9stainless-app[bot]4 months ago | 83 | with pytest.warns(DeprecationWarning): |
| 84 | permission = client.fine_tuning.checkpoints.permissions.retrieve( | |
| 85 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 86 | after="after", | |
| 87 | limit=0, | |
| 88 | order="ascending", | |
| 89 | project_id="project_id", | |
| 90 | ) | |
| 91 | | |
| 92 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) | |
| 93 | | |
| 94 | @parametrize | |
| 95 | def test_raw_response_retrieve(self, client: OpenAI) -> None: | |
| 96 | with pytest.warns(DeprecationWarning): | |
| 97 | response = client.fine_tuning.checkpoints.permissions.with_raw_response.retrieve( | |
| 98 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 99 | ) | |
| 100 | | |
| 101 | assert response.is_closed is True | |
| 102 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 103 | permission = response.parse() | |
| 104 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) | |
| 105 | | |
| 106 | @parametrize | |
| 107 | def test_streaming_response_retrieve(self, client: OpenAI) -> None: | |
| 108 | with pytest.warns(DeprecationWarning): | |
| 109 | with client.fine_tuning.checkpoints.permissions.with_streaming_response.retrieve( | |
| 110 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 111 | ) as response: | |
| 112 | assert not response.is_closed | |
| 113 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 114 | | |
| 115 | permission = response.parse() | |
| 116 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) | |
| 117 | | |
| 118 | assert cast(Any, response.is_closed) is True | |
| 119 | | |
| 120 | @parametrize | |
| 121 | def test_path_params_retrieve(self, client: OpenAI) -> None: | |
| 122 | with pytest.warns(DeprecationWarning): | |
| 123 | with pytest.raises( | |
| 124 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 125 | ): | |
| 126 | client.fine_tuning.checkpoints.permissions.with_raw_response.retrieve( | |
| 127 | fine_tuned_model_checkpoint="", | |
| 128 | ) | |
| 129 | | |
| 130 | @parametrize | |
| 131 | def test_method_list(self, client: OpenAI) -> None: | |
| 132 | permission = client.fine_tuning.checkpoints.permissions.list( | |
| 133 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 134 | ) | |
| 135 | assert_matches_type(SyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) | |
| 136 | | |
| 137 | @parametrize | |
| 138 | def test_method_list_with_all_params(self, client: OpenAI) -> None: | |
| 139 | permission = client.fine_tuning.checkpoints.permissions.list( | |
7e8b3171stainless-app[bot]1 years ago | 140 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 141 | after="after", | |
| 142 | limit=0, | |
| 143 | order="ascending", | |
| 144 | project_id="project_id", | |
| 145 | ) | |
0c14b4b9stainless-app[bot]4 months ago | 146 | assert_matches_type(SyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 147 | |
| 148 | @parametrize | |
0c14b4b9stainless-app[bot]4 months ago | 149 | def test_raw_response_list(self, client: OpenAI) -> None: |
| 150 | response = client.fine_tuning.checkpoints.permissions.with_raw_response.list( | |
7e8b3171stainless-app[bot]1 years ago | 151 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 152 | ) | |
| 153 | | |
| 154 | assert response.is_closed is True | |
| 155 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 156 | permission = response.parse() | |
0c14b4b9stainless-app[bot]4 months ago | 157 | assert_matches_type(SyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 158 | |
| 159 | @parametrize | |
0c14b4b9stainless-app[bot]4 months ago | 160 | def test_streaming_response_list(self, client: OpenAI) -> None: |
| 161 | with client.fine_tuning.checkpoints.permissions.with_streaming_response.list( | |
7e8b3171stainless-app[bot]1 years ago | 162 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 163 | ) as response: | |
| 164 | assert not response.is_closed | |
| 165 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 166 | | |
| 167 | permission = response.parse() | |
0c14b4b9stainless-app[bot]4 months ago | 168 | assert_matches_type(SyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 169 | |
| 170 | assert cast(Any, response.is_closed) is True | |
| 171 | | |
| 172 | @parametrize | |
0c14b4b9stainless-app[bot]4 months ago | 173 | def test_path_params_list(self, client: OpenAI) -> None: |
7e8b3171stainless-app[bot]1 years ago | 174 | with pytest.raises( |
| 175 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 176 | ): | |
0c14b4b9stainless-app[bot]4 months ago | 177 | client.fine_tuning.checkpoints.permissions.with_raw_response.list( |
7e8b3171stainless-app[bot]1 years ago | 178 | fine_tuned_model_checkpoint="", |
| 179 | ) | |
| 180 | | |
| 181 | @parametrize | |
| 182 | def test_method_delete(self, client: OpenAI) -> None: | |
| 183 | permission = client.fine_tuning.checkpoints.permissions.delete( | |
13640c08stainless-app[bot]1 years ago | 184 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 185 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 186 | ) |
| 187 | assert_matches_type(PermissionDeleteResponse, permission, path=["response"]) | |
| 188 | | |
| 189 | @parametrize | |
| 190 | def test_raw_response_delete(self, client: OpenAI) -> None: | |
| 191 | response = client.fine_tuning.checkpoints.permissions.with_raw_response.delete( | |
13640c08stainless-app[bot]1 years ago | 192 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 193 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 194 | ) |
| 195 | | |
| 196 | assert response.is_closed is True | |
| 197 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 198 | permission = response.parse() | |
| 199 | assert_matches_type(PermissionDeleteResponse, permission, path=["response"]) | |
| 200 | | |
| 201 | @parametrize | |
| 202 | def test_streaming_response_delete(self, client: OpenAI) -> None: | |
| 203 | with client.fine_tuning.checkpoints.permissions.with_streaming_response.delete( | |
13640c08stainless-app[bot]1 years ago | 204 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 205 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 206 | ) as response: |
| 207 | assert not response.is_closed | |
| 208 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 209 | | |
| 210 | permission = response.parse() | |
| 211 | assert_matches_type(PermissionDeleteResponse, permission, path=["response"]) | |
| 212 | | |
| 213 | assert cast(Any, response.is_closed) is True | |
| 214 | | |
| 215 | @parametrize | |
| 216 | def test_path_params_delete(self, client: OpenAI) -> None: | |
| 217 | with pytest.raises( | |
| 218 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 219 | ): | |
| 220 | client.fine_tuning.checkpoints.permissions.with_raw_response.delete( | |
13640c08stainless-app[bot]1 years ago | 221 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 222 | fine_tuned_model_checkpoint="", | |
| 223 | ) | |
| 224 | | |
| 225 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `permission_id` but received ''"): | |
| 226 | client.fine_tuning.checkpoints.permissions.with_raw_response.delete( | |
| 227 | permission_id="", | |
| 228 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 229 | ) |
| 230 | | |
| 231 | | |
| 232 | class TestAsyncPermissions: | |
d7700afdstainless-app[bot]1 years ago | 233 | parametrize = pytest.mark.parametrize( |
| 234 | "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] | |
| 235 | ) | |
7e8b3171stainless-app[bot]1 years ago | 236 | |
| 237 | @parametrize | |
| 238 | async def test_method_create(self, async_client: AsyncOpenAI) -> None: | |
| 239 | permission = await async_client.fine_tuning.checkpoints.permissions.create( | |
| 240 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
| 241 | project_ids=["string"], | |
| 242 | ) | |
| 243 | assert_matches_type(AsyncPage[PermissionCreateResponse], permission, path=["response"]) | |
| 244 | | |
| 245 | @parametrize | |
| 246 | async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: | |
| 247 | response = await async_client.fine_tuning.checkpoints.permissions.with_raw_response.create( | |
| 248 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
| 249 | project_ids=["string"], | |
| 250 | ) | |
| 251 | | |
| 252 | assert response.is_closed is True | |
| 253 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 254 | permission = response.parse() | |
| 255 | assert_matches_type(AsyncPage[PermissionCreateResponse], permission, path=["response"]) | |
| 256 | | |
| 257 | @parametrize | |
| 258 | async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: | |
| 259 | async with async_client.fine_tuning.checkpoints.permissions.with_streaming_response.create( | |
| 260 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
| 261 | project_ids=["string"], | |
| 262 | ) as response: | |
| 263 | assert not response.is_closed | |
| 264 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 265 | | |
| 266 | permission = await response.parse() | |
| 267 | assert_matches_type(AsyncPage[PermissionCreateResponse], permission, path=["response"]) | |
| 268 | | |
| 269 | assert cast(Any, response.is_closed) is True | |
| 270 | | |
| 271 | @parametrize | |
| 272 | async def test_path_params_create(self, async_client: AsyncOpenAI) -> None: | |
| 273 | with pytest.raises( | |
| 274 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 275 | ): | |
| 276 | await async_client.fine_tuning.checkpoints.permissions.with_raw_response.create( | |
| 277 | fine_tuned_model_checkpoint="", | |
| 278 | project_ids=["string"], | |
| 279 | ) | |
| 280 | | |
| 281 | @parametrize | |
| 282 | async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: | |
0c14b4b9stainless-app[bot]4 months ago | 283 | with pytest.warns(DeprecationWarning): |
| 284 | permission = await async_client.fine_tuning.checkpoints.permissions.retrieve( | |
| 285 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 286 | ) | |
| 287 | | |
8707913dstainless-app[bot]1 years ago | 288 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 289 | |
| 290 | @parametrize | |
| 291 | async def test_method_retrieve_with_all_params(self, async_client: AsyncOpenAI) -> None: | |
0c14b4b9stainless-app[bot]4 months ago | 292 | with pytest.warns(DeprecationWarning): |
| 293 | permission = await async_client.fine_tuning.checkpoints.permissions.retrieve( | |
| 294 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 295 | after="after", | |
| 296 | limit=0, | |
| 297 | order="ascending", | |
| 298 | project_id="project_id", | |
| 299 | ) | |
| 300 | | |
| 301 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) | |
| 302 | | |
| 303 | @parametrize | |
| 304 | async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: | |
| 305 | with pytest.warns(DeprecationWarning): | |
| 306 | response = await async_client.fine_tuning.checkpoints.permissions.with_raw_response.retrieve( | |
| 307 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 308 | ) | |
| 309 | | |
| 310 | assert response.is_closed is True | |
| 311 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 312 | permission = response.parse() | |
| 313 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) | |
| 314 | | |
| 315 | @parametrize | |
| 316 | async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: | |
| 317 | with pytest.warns(DeprecationWarning): | |
| 318 | async with async_client.fine_tuning.checkpoints.permissions.with_streaming_response.retrieve( | |
| 319 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 320 | ) as response: | |
| 321 | assert not response.is_closed | |
| 322 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 323 | | |
| 324 | permission = await response.parse() | |
| 325 | assert_matches_type(PermissionRetrieveResponse, permission, path=["response"]) | |
| 326 | | |
| 327 | assert cast(Any, response.is_closed) is True | |
| 328 | | |
| 329 | @parametrize | |
| 330 | async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: | |
| 331 | with pytest.warns(DeprecationWarning): | |
| 332 | with pytest.raises( | |
| 333 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 334 | ): | |
| 335 | await async_client.fine_tuning.checkpoints.permissions.with_raw_response.retrieve( | |
| 336 | fine_tuned_model_checkpoint="", | |
| 337 | ) | |
| 338 | | |
| 339 | @parametrize | |
| 340 | async def test_method_list(self, async_client: AsyncOpenAI) -> None: | |
| 341 | permission = await async_client.fine_tuning.checkpoints.permissions.list( | |
| 342 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", | |
| 343 | ) | |
| 344 | assert_matches_type(AsyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) | |
| 345 | | |
| 346 | @parametrize | |
| 347 | async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: | |
| 348 | permission = await async_client.fine_tuning.checkpoints.permissions.list( | |
7e8b3171stainless-app[bot]1 years ago | 349 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 350 | after="after", | |
| 351 | limit=0, | |
| 352 | order="ascending", | |
| 353 | project_id="project_id", | |
| 354 | ) | |
0c14b4b9stainless-app[bot]4 months ago | 355 | assert_matches_type(AsyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 356 | |
| 357 | @parametrize | |
0c14b4b9stainless-app[bot]4 months ago | 358 | async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: |
| 359 | response = await async_client.fine_tuning.checkpoints.permissions.with_raw_response.list( | |
7e8b3171stainless-app[bot]1 years ago | 360 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 361 | ) | |
| 362 | | |
| 363 | assert response.is_closed is True | |
| 364 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 365 | permission = response.parse() | |
0c14b4b9stainless-app[bot]4 months ago | 366 | assert_matches_type(AsyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 367 | |
| 368 | @parametrize | |
0c14b4b9stainless-app[bot]4 months ago | 369 | async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: |
| 370 | async with async_client.fine_tuning.checkpoints.permissions.with_streaming_response.list( | |
7e8b3171stainless-app[bot]1 years ago | 371 | fine_tuned_model_checkpoint="ft-AF1WoRqd3aJAHsqc9NY7iL8F", |
| 372 | ) as response: | |
| 373 | assert not response.is_closed | |
| 374 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 375 | | |
| 376 | permission = await response.parse() | |
0c14b4b9stainless-app[bot]4 months ago | 377 | assert_matches_type(AsyncConversationCursorPage[PermissionListResponse], permission, path=["response"]) |
7e8b3171stainless-app[bot]1 years ago | 378 | |
| 379 | assert cast(Any, response.is_closed) is True | |
| 380 | | |
| 381 | @parametrize | |
0c14b4b9stainless-app[bot]4 months ago | 382 | async def test_path_params_list(self, async_client: AsyncOpenAI) -> None: |
7e8b3171stainless-app[bot]1 years ago | 383 | with pytest.raises( |
| 384 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 385 | ): | |
0c14b4b9stainless-app[bot]4 months ago | 386 | await async_client.fine_tuning.checkpoints.permissions.with_raw_response.list( |
7e8b3171stainless-app[bot]1 years ago | 387 | fine_tuned_model_checkpoint="", |
| 388 | ) | |
| 389 | | |
| 390 | @parametrize | |
| 391 | async def test_method_delete(self, async_client: AsyncOpenAI) -> None: | |
| 392 | permission = await async_client.fine_tuning.checkpoints.permissions.delete( | |
13640c08stainless-app[bot]1 years ago | 393 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 394 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 395 | ) |
| 396 | assert_matches_type(PermissionDeleteResponse, permission, path=["response"]) | |
| 397 | | |
| 398 | @parametrize | |
| 399 | async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None: | |
| 400 | response = await async_client.fine_tuning.checkpoints.permissions.with_raw_response.delete( | |
13640c08stainless-app[bot]1 years ago | 401 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 402 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 403 | ) |
| 404 | | |
| 405 | assert response.is_closed is True | |
| 406 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 407 | permission = response.parse() | |
| 408 | assert_matches_type(PermissionDeleteResponse, permission, path=["response"]) | |
| 409 | | |
| 410 | @parametrize | |
| 411 | async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None: | |
| 412 | async with async_client.fine_tuning.checkpoints.permissions.with_streaming_response.delete( | |
13640c08stainless-app[bot]1 years ago | 413 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 414 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 415 | ) as response: |
| 416 | assert not response.is_closed | |
| 417 | assert response.http_request.headers.get("X-Stainless-Lang") == "python" | |
| 418 | | |
| 419 | permission = await response.parse() | |
| 420 | assert_matches_type(PermissionDeleteResponse, permission, path=["response"]) | |
| 421 | | |
| 422 | assert cast(Any, response.is_closed) is True | |
| 423 | | |
| 424 | @parametrize | |
| 425 | async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None: | |
| 426 | with pytest.raises( | |
| 427 | ValueError, match=r"Expected a non-empty value for `fine_tuned_model_checkpoint` but received ''" | |
| 428 | ): | |
| 429 | await async_client.fine_tuning.checkpoints.permissions.with_raw_response.delete( | |
13640c08stainless-app[bot]1 years ago | 430 | permission_id="cp_zc4Q7MP6XxulcVzj4MZdwsAB", |
| 431 | fine_tuned_model_checkpoint="", | |
| 432 | ) | |
| 433 | | |
| 434 | with pytest.raises(ValueError, match=r"Expected a non-empty value for `permission_id` but received ''"): | |
| 435 | await async_client.fine_tuning.checkpoints.permissions.with_raw_response.delete( | |
| 436 | permission_id="", | |
| 437 | fine_tuned_model_checkpoint="ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd", | |
7e8b3171stainless-app[bot]1 years ago | 438 | ) |