|
23 | 23 | AccessTokenForConnectionError, |
24 | 24 | ApiError, |
25 | 25 | BackchannelLogoutError, |
| 26 | + InvalidArgumentError, |
26 | 27 | MissingRequiredArgumentError, |
27 | 28 | MissingTransactionError, |
28 | 29 | PollingApiError, |
@@ -1937,6 +1938,31 @@ async def test_complete_connect_account_no_transactions(mocker): |
1937 | 1938 | assert "transaction" in str(exc.value) |
1938 | 1939 | mock_my_account_client.complete_connect_account.assert_not_awaited() |
1939 | 1940 |
|
| 1941 | +@pytest.mark.asyncio |
| 1942 | +@pytest.mark.parametrize("take", ["not_an_integer", 21.3, -5, 0]) |
| 1943 | +async def test_list_connected_accounts__with_invalid_take_param(mocker, take): |
| 1944 | + # Setup |
| 1945 | + client = ServerClient( |
| 1946 | + domain="auth0.local", |
| 1947 | + client_id="<client_id>", |
| 1948 | + client_secret="<client_secret>", |
| 1949 | + secret="some-secret" |
| 1950 | + ) |
| 1951 | + mock_my_account_client = AsyncMock(MyAccountClient) |
| 1952 | + mocker.patch.object(client, "_my_account_client", mock_my_account_client) |
| 1953 | + |
| 1954 | + # Act |
| 1955 | + with pytest.raises(InvalidArgumentError) as exc: |
| 1956 | + await client.list_connected_accounts( |
| 1957 | + connection="<connection>", |
| 1958 | + from_param="<from_param>", |
| 1959 | + take=take |
| 1960 | + ) |
| 1961 | + |
| 1962 | + # Assert |
| 1963 | + assert "The 'take' parameter must be a positive integer." in str(exc.value) |
| 1964 | + mock_my_account_client.list_connected_accounts.assert_not_awaited() |
| 1965 | + |
1940 | 1966 | @pytest.mark.asyncio |
1941 | 1967 | async def test_list_connected_accounts_gets_access_token_and_calls_my_account(mocker): |
1942 | 1968 | # Setup |
@@ -2022,6 +2048,26 @@ async def test_delete_connected_account_gets_access_token_and_calls_my_account(m |
2022 | 2048 | connected_account_id="<id>" |
2023 | 2049 | ) |
2024 | 2050 |
|
| 2051 | +@pytest.mark.asyncio |
| 2052 | +async def test_delete_connected_account_with_empty_connected_account_id(mocker): |
| 2053 | + # Setup |
| 2054 | + client = ServerClient( |
| 2055 | + domain="auth0.local", |
| 2056 | + client_id="<client_id>", |
| 2057 | + client_secret="<client_secret>", |
| 2058 | + secret="some-secret" |
| 2059 | + ) |
| 2060 | + mock_my_account_client = AsyncMock(MyAccountClient) |
| 2061 | + mocker.patch.object(client, "_my_account_client", mock_my_account_client) |
| 2062 | + |
| 2063 | + # Act |
| 2064 | + with pytest.raises(MissingRequiredArgumentError) as exc: |
| 2065 | + await client.delete_connected_account(connected_account_id=None) |
| 2066 | + |
| 2067 | + # Assert |
| 2068 | + assert "connected_account_id" in str(exc.value) |
| 2069 | + mock_my_account_client.delete_connected_account.assert_not_awaited() |
| 2070 | + |
2025 | 2071 | @pytest.mark.asyncio |
2026 | 2072 | async def test_list_connected_account_connections_gets_access_token_and_calls_my_account(mocker): |
2027 | 2073 | # Setup |
@@ -2069,3 +2115,27 @@ async def test_list_connected_account_connections_gets_access_token_and_calls_my |
2069 | 2115 | from_param="<from_param>", |
2070 | 2116 | take=2 |
2071 | 2117 | ) |
| 2118 | + |
| 2119 | +@pytest.mark.asyncio |
| 2120 | +@pytest.mark.parametrize("take", ["not_an_integer", 21.3, -5, 0]) |
| 2121 | +async def test_list_connected_account_connections_with_invalid_take_param(mocker, take): |
| 2122 | + # Setup |
| 2123 | + client = ServerClient( |
| 2124 | + domain="auth0.local", |
| 2125 | + client_id="<client_id>", |
| 2126 | + client_secret="<client_secret>", |
| 2127 | + secret="some-secret" |
| 2128 | + ) |
| 2129 | + mock_my_account_client = AsyncMock(MyAccountClient) |
| 2130 | + mocker.patch.object(client, "_my_account_client", mock_my_account_client) |
| 2131 | + |
| 2132 | + # Act |
| 2133 | + with pytest.raises(InvalidArgumentError) as exc: |
| 2134 | + await client.list_connected_account_connections( |
| 2135 | + from_param="<from_param>", |
| 2136 | + take=take |
| 2137 | + ) |
| 2138 | + |
| 2139 | + # Assert |
| 2140 | + assert "The 'take' parameter must be a positive integer." in str(exc.value) |
| 2141 | + mock_my_account_client.list_connected_account_connections.assert_not_awaited() |
0 commit comments