diff --git a/client/tests/sdk/test_api.py b/client/tests/sdk/test_api.py index 5424cc6649..c7870aae49 100644 --- a/client/tests/sdk/test_api.py +++ b/client/tests/sdk/test_api.py @@ -6,10 +6,9 @@ import pyotp import pytest import vcr -from requests.exceptions import ConnectTimeout, ReadTimeout from test_shared import TestShared -from securedrop_client.sdk import API, RequestTimeoutError +from securedrop_client.sdk import API, RequestTimeoutError, ServerConnectionError from securedrop_client.sdk.sdlocalobjects import AuthError, Reply, Submission NUM_REPLIES_PER_SOURCE = 2 @@ -247,21 +246,21 @@ def test_zlogout(self): def test_request_connect_timeout(mocker): api = API("mock", "mock", "mock", "mock", proxy=False) - mocker.patch("securedrop_client.sdk.requests.request", side_effect=ConnectTimeout) - with pytest.raises(RequestTimeoutError): + mocker.patch("securedrop_client.sdk.API._send_json_request", side_effect=ServerConnectionError) + with pytest.raises(ServerConnectionError): api.authenticate() def test_request_read_timeout(mocker): api = API("mock", "mock", "mock", "mock", proxy=False) - mocker.patch("securedrop_client.sdk.requests.request", side_effect=ReadTimeout) + mocker.patch("securedrop_client.sdk.API._send_json_request", side_effect=RequestTimeoutError) with pytest.raises(RequestTimeoutError): api.authenticate() def test_download_reply_timeout(mocker): api = API("mock", "mock", "mock", "mock", proxy=False) - mocker.patch("securedrop_client.sdk.requests.request", side_effect=RequestTimeoutError) + mocker.patch("securedrop_client.sdk.API._send_json_request", side_effect=RequestTimeoutError) with pytest.raises(RequestTimeoutError): r = Reply(uuid="humanproblem", filename="secret.txt") api.download_reply(r) @@ -269,7 +268,7 @@ def test_download_reply_timeout(mocker): def test_download_submission_timeout(mocker): api = API("mock", "mock", "mock", "mock", proxy=False) - mocker.patch("securedrop_client.sdk.requests.request", side_effect=RequestTimeoutError) + mocker.patch("securedrop_client.sdk.API._send_json_request", side_effect=RequestTimeoutError) with pytest.raises(RequestTimeoutError): s = Submission(uuid="climateproblem") api.download_submission(s)