mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 07:03:56 -06:00
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.
This commit is contained in:
parent
8ea8cc752f
commit
3236be1c20
1 changed files with 4 additions and 2 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue