Skip to content

Commit

Permalink
fix mypy lint on HTTPError
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanhphan1147 committed Sep 25, 2023
1 parent 2af3767 commit 18210df
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/unit/test_synapse_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def test_register_user_error(mock_session, monkeypatch: pytest.MonkeyPatch):

mock_response_exception = mock.MagicMock()
mock_response_exception.text = "Fail"
mock_response_http_error = requests.exceptions.HTTPError(response=mock_response_exception)
mock_response_http_error = requests.exceptions.HTTPError(
request=mock.Mock(), response=mock_response_exception
)
mock_request = mock.Mock()
mock_request.request.side_effect = mock_response_http_error
mock_session.return_value = mock_request
Expand Down Expand Up @@ -146,7 +148,9 @@ def test_register_user_exists_error(mock_session, monkeypatch: pytest.MonkeyPatc
shared_secret = token_hex(16)
mock_response_exception = mock.MagicMock()
mock_response_exception.text = "User ID already taken"
mock_response_http_error = requests.exceptions.HTTPError(response=mock_response_exception)
mock_response_http_error = requests.exceptions.HTTPError(
request=mock.Mock(), response=mock_response_exception
)
mock_request = mock.Mock()
mock_request.request.side_effect = mock_response_http_error
mock_session.return_value = mock_request
Expand Down Expand Up @@ -558,7 +562,9 @@ def test_get_nonce_requests_error(mock_session):
synapse.api._get_nonce()
mock_response_exception = mock.MagicMock()
mock_response_exception.text = "Fail"
mock_response_http_error = requests.exceptions.HTTPError(response=mock_response_exception)
mock_response_http_error = requests.exceptions.HTTPError(
request=mock.Mock(), response=mock_response_exception
)
mock_request = mock.Mock()
mock_request.request.side_effect = mock_response_http_error
mock_session.return_value = mock_request
Expand Down Expand Up @@ -609,7 +615,9 @@ def test_get_version_requests_error(mock_session):

mock_response_exception = mock.MagicMock()
mock_response_exception.text = "Fail"
mock_response_http_error = requests.exceptions.HTTPError(response=mock_response_exception)
mock_response_http_error = requests.exceptions.HTTPError(
request=mock.Mock(), response=mock_response_exception
)
mock_requests = mock.MagicMock()
mock_requests.request.side_effect = mock_response_http_error
mock_session.return_value = mock_requests
Expand Down

0 comments on commit 18210df

Please sign in to comment.