Skip to content

Commit

Permalink
Add: Unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
n-thumann authored and greenbonebot committed Nov 10, 2023
1 parent 0f9fa1d commit 4af2650
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/nvd/cve_change_history/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4af2650

Please sign in to comment.