diff options
author | Ghostkeeper <rubend@tutanota.com> | 2021-11-22 16:45:44 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2021-11-22 16:45:44 +0300 |
commit | 3236be1c2002d4cea2d1452ec3c3d4bb6f712f58 (patch) | |
tree | 414bb530e3b3a5e6514b5f1423de7ffffe2c3d15 /tests/TestOAuth2.py | |
parent | 8ea8cc752fe3addb9e0eb8a13ec205e8d3a51c0a (diff) |
Also mock POST command and a failed response
Otherwise it'll end up using actual internet connections anyway. Not what we want.
Contributes to issue CURA-8539.
Diffstat (limited to 'tests/TestOAuth2.py')
-rw-r--r-- | tests/TestOAuth2.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/TestOAuth2.py b/tests/TestOAuth2.py index bc5dc21553..9993440ed4 100644 --- a/tests/TestOAuth2.py +++ b/tests/TestOAuth2.py @@ -120,9 +120,11 @@ def test__parseJWTFailOnRefresh(): mock_reply.error = Mock(return_value = QNetworkReply.NetworkError.AuthenticationRequiredError) # The reply is 403: Authentication required, meaning the server responded with a "Can't do that, Dave". http_mock = Mock() http_mock.get = lambda url, headers_dict, callback, error_callback: callback(mock_reply) + http_mock.post = lambda url, data, headers_dict, callback, error_callback: callback(mock_reply) - with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", MagicMock(return_value = http_mock)): - authorization_service._parseJWT(mock_callback) + with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.readJSON", Mock(return_value = {"error_description": "Mock a failed request!"})): + with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance", MagicMock(return_value = http_mock)): + authorization_service._parseJWT(mock_callback) mock_callback.assert_called_once_with(None) def test__parseJWTSucceedOnRefresh(): |