Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Aureliano da Silva Maia committed Oct 23, 2023
1 parent 053d22f commit 1fb7c48
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/unit/test_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,26 @@ def test_reset(client):
expected_user_agent = f"{__title__}/{__version__}"
assert "Test-Header" not in client.session.headers
assert client.session.headers["User-Agent"] == expected_user_agent


def test_get_generic_exception(client, mocker):
"""Test GET request with generic exception."""
mock_get = mocker.patch("requests.Session.get")
mock_get.side_effect = Exception("Some Exception")

with pytest.raises(SystemExit):
client.get("http://test.com")


def test_post_generic_exception(client, mocker):
"""Test POST request with generic exception."""
mock_post = mocker.patch("requests.Session.post")
mock_post.side_effect = Exception("Some Exception")

with pytest.raises(SystemExit):
client.post("http://test.com", json={"key": "value"})


def test_post_json_exception(client, mocker):
"""Test POST request when json() method raises an exception."""
mock_post = mocker.patch("requests.Session.post")
Expand All @@ -132,6 +134,7 @@ def test_post_json_exception(client, mocker):
with pytest.raises(SystemExit):
client.post("http://test.com", json={"key": "value"}, return_json=True)


def test_get_logging_on_exception(client, mocker):
"""Test if logging occurs during exception in GET request."""
mock_get = mocker.patch("requests.Session.get")
Expand All @@ -142,6 +145,7 @@ def test_get_logging_on_exception(client, mocker):
client.get("http://test.com")
mock_logger.assert_called()


def test_post_logging_on_exception(client, mocker):
"""Test if logging occurs during exception in POST request."""
mock_post = mocker.patch("requests.Session.post")
Expand All @@ -151,4 +155,3 @@ def test_post_logging_on_exception(client, mocker):
with pytest.raises(SystemExit):
client.post("http://test.com", json={"key": "value"})
mock_logger.assert_called()

0 comments on commit 1fb7c48

Please sign in to comment.