Skip to content

Commit

Permalink
Add: Unit test to empty result behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
n-thumann committed Aug 13, 2024
1 parent 26d05ce commit 5f038c5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/nvd/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,29 @@ async def test_items(self):
with self.assertRaises(StopAsyncIteration):
await anext(it)

async def test_items_no_results(self):
response_mock = MagicMock(spec=Response)
response_mock.json.side_effect = [
{
"values": [],
"total_results": 0,
"results_per_page": 0,
},
]
api_mock = AsyncMock(spec=NVDApi)
api_mock._get.return_value = response_mock

results: NVDResults[Result] = NVDResults(
api_mock,
{},
result_func,
)

it = aiter(results.items())

with self.assertRaises(StopAsyncIteration):
await anext(it)

async def test_aiter(self):
response_mock = MagicMock(spec=Response)
response_mock.json.side_effect = [
Expand Down

0 comments on commit 5f038c5

Please sign in to comment.