diff --git a/tests/test_web.py b/tests/test_web.py index f2bcee0..0716335 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -4,6 +4,8 @@ import unittest import time import os +from datetime import datetime, timezone, timedelta + from pyvulnerabilitylookup import PyVulnerabilityLookup # NOTE: @@ -307,3 +309,36 @@ class TestPublic(unittest.TestCase): self.assertTrue(len(comments['data']) == 0, comments) deleted_comment = self.client.delete_comment(new_comment_uuid) self.assertTrue(deleted_comment < 300) + + # test Sightings + def test_sightings(self) -> None: + sighting_cve = self.client.get_sighting('6febe45d-d8de-4df7-b3ba-6cf7acd2e2b5') + self.assertTrue(sighting_cve) + self.assertTrue('uuid' in sighting_cve) + self.assertEqual(sighting_cve['uuid'], '6febe45d-d8de-4df7-b3ba-6cf7acd2e2b5') + + sighting_cve_list = self.client.get_sightings(sighting_uuid='6febe45d-d8de-4df7-b3ba-6cf7acd2e2b5') + self.assertTrue(sighting_cve_list) + self.assertTrue('data' in sighting_cve_list) + self.assertTrue(len(sighting_cve_list['data']) == 1) + self.assertEqual(sighting_cve_list['data'][0], sighting_cve) + + sighting_cve_list = self.client.get_sightings(vuln_id='CVE-2020-3532') + self.assertTrue(sighting_cve_list) + self.assertTrue('data' in sighting_cve_list) + self.assertTrue(len(sighting_cve_list['data']) > 0) + + sighting_cve_list = self.client.get_sightings(author='automation') + self.assertTrue(sighting_cve_list) + self.assertTrue('data' in sighting_cve_list) + self.assertTrue(len(sighting_cve_list['data']) > 0) + + sighting_cve_list = self.client.get_sightings(author='automation', vuln_id='CVE-2020-3532') + self.assertTrue(sighting_cve_list) + self.assertTrue('data' in sighting_cve_list) + self.assertTrue(len(sighting_cve_list['data']) > 0) + + sighting_cve_list = self.client.get_sightings(author='automation', date_from=datetime.now(tz=timezone.utc) - timedelta(days=1), date_to=datetime.now(tz=timezone.utc)) + self.assertTrue(sighting_cve_list) + self.assertTrue('data' in sighting_cve_list) + self.assertTrue(len(sighting_cve_list['data']) > 0)