|
13 | 13 | ListConnectedAccountConnectionsResponse, |
14 | 14 | ListConnectedAccountResponse, |
15 | 15 | ) |
16 | | -from auth0_server_python.error import MyAccountApiError |
| 16 | +from auth0_server_python.error import ( |
| 17 | + InvalidArgumentError, |
| 18 | + MissingRequiredArgumentError, |
| 19 | + MyAccountApiError, |
| 20 | +) |
17 | 21 |
|
18 | 22 |
|
19 | 23 | @pytest.mark.asyncio |
@@ -228,6 +232,45 @@ async def test_list_connected_accounts_success(mocker): |
228 | 232 | next="<next_token>" |
229 | 233 | ) |
230 | 234 |
|
| 235 | +@pytest.mark.asyncio |
| 236 | +async def test_list_connected_accounts_missing_access_token(mocker): |
| 237 | + # Arrange |
| 238 | + client = MyAccountClient(domain="auth0.local") |
| 239 | + mock_get = mocker.patch("httpx.AsyncClient.get", new_callable=AsyncMock) |
| 240 | + |
| 241 | + # Act |
| 242 | + with pytest.raises(MissingRequiredArgumentError) as exc: |
| 243 | + await client.list_connected_accounts( |
| 244 | + access_token=None, |
| 245 | + connection="<connection>", |
| 246 | + from_param="<from_param>", |
| 247 | + take=2 |
| 248 | + ) |
| 249 | + |
| 250 | + # Assert |
| 251 | + mock_get.assert_not_awaited() |
| 252 | + assert "access_token" in str(exc.value) |
| 253 | + |
| 254 | +@pytest.mark.asyncio |
| 255 | +@pytest.mark.parametrize("take", ["not_an_integer", 21.3, -5, 0]) |
| 256 | +async def test_list_connected_accounts_invalid_take_param(mocker, take): |
| 257 | + # Arrange |
| 258 | + client = MyAccountClient(domain="auth0.local") |
| 259 | + mock_get = mocker.patch("httpx.AsyncClient.get", new_callable=AsyncMock) |
| 260 | + |
| 261 | + # Act |
| 262 | + with pytest.raises(InvalidArgumentError) as exc: |
| 263 | + await client.list_connected_accounts( |
| 264 | + access_token="<access_token>", |
| 265 | + connection="<connection>", |
| 266 | + from_param="<from_param>", |
| 267 | + take=take |
| 268 | + ) |
| 269 | + |
| 270 | + # Assert |
| 271 | + mock_get.assert_not_awaited() |
| 272 | + assert "The 'take' parameter must be a positive integer." in str(exc.value) |
| 273 | + |
231 | 274 | @pytest.mark.asyncio |
232 | 275 | async def test_list_connected_accounts_api_response_failure(mocker): |
233 | 276 | # Arrange |
@@ -277,6 +320,40 @@ async def test_delete_connected_account_success(mocker): |
277 | 320 | auth=ANY |
278 | 321 | ) |
279 | 322 |
|
| 323 | +@pytest.mark.asyncio |
| 324 | +async def test_delete_connected_account_missing_access_token(mocker): |
| 325 | + # Arrange |
| 326 | + client = MyAccountClient(domain="auth0.local") |
| 327 | + mock_delete = mocker.patch("httpx.AsyncClient.delete", new_callable=AsyncMock) |
| 328 | + |
| 329 | + # Act |
| 330 | + with pytest.raises(MissingRequiredArgumentError) as exc: |
| 331 | + await client.delete_connected_account( |
| 332 | + access_token=None, |
| 333 | + connected_account_id="<id_1>" |
| 334 | + ) |
| 335 | + |
| 336 | + # Assert |
| 337 | + mock_delete.assert_not_awaited() |
| 338 | + assert "access_token" in str(exc.value) |
| 339 | + |
| 340 | +@pytest.mark.asyncio |
| 341 | +async def test_delete_connected_account_missing_connected_account_id(mocker): |
| 342 | + # Arrange |
| 343 | + client = MyAccountClient(domain="auth0.local") |
| 344 | + mock_delete = mocker.patch("httpx.AsyncClient.delete", new_callable=AsyncMock) |
| 345 | + |
| 346 | + # Act |
| 347 | + with pytest.raises(MissingRequiredArgumentError) as exc: |
| 348 | + await client.delete_connected_account( |
| 349 | + access_token="<access_token>", |
| 350 | + connected_account_id=None |
| 351 | + ) |
| 352 | + |
| 353 | + # Assert |
| 354 | + mock_delete.assert_not_awaited() |
| 355 | + assert "connected_account_id" in str(exc.value) |
| 356 | + |
280 | 357 | @pytest.mark.asyncio |
281 | 358 | async def test_delete_connected_account_api_response_failure(mocker): |
282 | 359 | # Arrange |
@@ -359,6 +436,44 @@ async def test_list_connected_account_connections_success(mocker): |
359 | 436 | next="<next_token>" |
360 | 437 | ) |
361 | 438 |
|
| 439 | +@pytest.mark.asyncio |
| 440 | +async def test_list_connected_account_connections_missing_access_token(mocker): |
| 441 | + # Arrange |
| 442 | + client = MyAccountClient(domain="auth0.local") |
| 443 | + mock_get = mocker.patch("httpx.AsyncClient.get", new_callable=AsyncMock) |
| 444 | + |
| 445 | + # Act |
| 446 | + with pytest.raises(MissingRequiredArgumentError) as exc: |
| 447 | + await client.list_connected_account_connections( |
| 448 | + access_token=None, |
| 449 | + from_param="<from_param>", |
| 450 | + take=2 |
| 451 | + ) |
| 452 | + |
| 453 | + # Assert |
| 454 | + mock_get.assert_not_awaited() |
| 455 | + assert "access_token" in str(exc.value) |
| 456 | + |
| 457 | +@pytest.mark.asyncio |
| 458 | +@pytest.mark.parametrize("take", ["not_an_integer", 21.3, -5, 0]) |
| 459 | +async def test_list_connected_account_connections_invalid_take_param(mocker, take): |
| 460 | + # Arrange |
| 461 | + client = MyAccountClient(domain="auth0.local") |
| 462 | + mock_get = mocker.patch("httpx.AsyncClient.get", new_callable=AsyncMock) |
| 463 | + |
| 464 | + # Act |
| 465 | + with pytest.raises(InvalidArgumentError) as exc: |
| 466 | + await client.list_connected_account_connections( |
| 467 | + access_token="<access_token>", |
| 468 | + from_param="<from_param>", |
| 469 | + take=take |
| 470 | + ) |
| 471 | + |
| 472 | + # Assert |
| 473 | + mock_get.assert_not_awaited() |
| 474 | + assert "The 'take' parameter must be a positive integer." in str(exc.value) |
| 475 | + |
| 476 | + |
362 | 477 | @pytest.mark.asyncio |
363 | 478 | async def test_list_connected_account_connections_api_response_failure(mocker): |
364 | 479 | # Arrange |
|
0 commit comments