Skip to content

Commit

Permalink
Change: Fix unit test for full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
n-thumann committed Dec 12, 2024
1 parent d3846ad commit fd81880
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/nvd/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ async def test_retry(
sleep_mock: MagicMock,
):
response_mocks = [
MagicMock(spec=Response, status_code=500),
MagicMock(spec=Response, status_code=500),
MagicMock(spec=Response, status_code=500),
MagicMock(spec=Response, status_code=200),
MagicMock(spec=Response, is_server_error=True),
MagicMock(spec=Response, is_server_error=True),
MagicMock(spec=Response, is_server_error=True),
MagicMock(spec=Response, is_server_error=False),
]
http_client = AsyncMock()
http_client.get.side_effect = response_mocks
Expand All @@ -152,7 +152,7 @@ async def test_retry(

calls = [call(2.0), call(4.0), call(8.0)]
sleep_mock.assert_has_calls(calls)
self.assertEqual(result.status_code, 200)
self.assertFalse(result.is_server_error)

@patch("pontos.nvd.api.asyncio.sleep", autospec=True)
@patch("pontos.nvd.api.AsyncClient", spec=AsyncClient)
Expand All @@ -162,7 +162,7 @@ async def test_no_retry(
sleep_mock: MagicMock,
):
response_mock = MagicMock(spec=Response)
response_mock.status_code = 200
response_mock.is_server_error = False

http_client = AsyncMock()
http_client.get.return_value = response_mock
Expand All @@ -173,7 +173,7 @@ async def test_no_retry(
result = await api._get()

sleep_mock.assert_not_called()
self.assertEqual(result.status_code, 200)
self.assertFalse(result.is_server_error)


class Result:
Expand Down

0 comments on commit fd81880

Please sign in to comment.