From 4af26502c252d39517864f2b7b296cefffdccaea Mon Sep 17 00:00:00 2001 From: Nicolas Thumann Date: Tue, 7 Nov 2023 14:43:39 +0100 Subject: [PATCH] Add: Unit tests --- tests/nvd/cve_change_history/test_api.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/nvd/cve_change_history/test_api.py b/tests/nvd/cve_change_history/test_api.py index 00a7fdf31..2df5f77fc 100644 --- a/tests/nvd/cve_change_history/test_api.py +++ b/tests/nvd/cve_change_history/test_api.py @@ -23,6 +23,7 @@ from httpx import AsyncClient, Response +from pontos.errors import PontosError from pontos.nvd.cve_change_history.api import CVEChangeHistoryApi from pontos.nvd.models.cve_change import Detail, EventName from tests import AsyncMock, IsolatedAsyncioTestCase, aiter, anext @@ -218,6 +219,25 @@ async def test_cve_changes_event_name(self): with self.assertRaises(StopAsyncIteration): cve_changes = await anext(it) + async def test_cve_changes_no_dates(self): + it = aiter(self.api.cve_changes(change_start_date=datetime(2023, 1, 1))) + with self.assertRaises(PontosError): + await anext(it) + + it = aiter(self.api.cve_changes(change_end_date=datetime(2023, 1, 1))) + with self.assertRaises(PontosError): + await anext(it) + + async def test_cve_changes_range_too_long(self): + it = aiter( + self.api.cve_changes( + change_start_date=datetime(2023, 1, 1), + change_end_date=datetime(2023, 5, 2), + ) + ) + with self.assertRaises(PontosError): + await anext(it) + async def test_context_manager(self): async with self.api: pass