def test_update_metadata_field_name_failed(self): notus = NotusMetadataHandler(metadata_path="./tests/notus") logging.Logger.warning = MagicMock() path = Path("./tests/notus/example.csv").resolve() notus._get_csv_filepaths = MagicMock(return_value=[path]) notus.is_checksum_correct = MagicMock(return_value=True) notus._check_field_names_lsc = MagicMock(return_value=False) notus.update_metadata() logging.Logger.warning.assert_called_with( f'Field names check for %s failed', path)
def test_update_metadata_success(self): notus = NotusMetadataHandler(metadata_path="./tests/notus") logging.Logger.warning = MagicMock() path = Path("./tests/notus/example.csv").resolve() purepath = PurePath(path).name notus._get_csv_filepaths = MagicMock(return_value=[path]) notus.is_checksum_correct = MagicMock(return_value=True) notus._check_field_names_lsc = MagicMock(return_value=True) notus.upload_lsc_from_csv_reader = MagicMock(return_value=True) notus.update_metadata() logging.Logger.warning.assert_not_called()
def test_update_metadata_failed(self): notus = NotusMetadataHandler(metadata_path="./tests/notus") logging.Logger.warning = MagicMock() path = Path("./tests/notus/example.csv").resolve() notus._get_csv_filepaths = MagicMock(return_value=[path]) notus.is_checksum_correct = MagicMock(return_value=True) notus._check_field_names_lsc = MagicMock(return_value=True) notus.upload_lsc_from_csv_reader = MagicMock(return_value=False) notus.update_metadata() logging.Logger.warning.assert_called_with( "Some advaisory was not loaded from %s", path.name)
def test_check_field_names_lsc_missing(self): notus = NotusMetadataHandler() field_names_list = [ "OID", "CREATION_DATE", "LAST_MODIFICATION", "SOURCE_PKGS", "ADVISORY_ID", "CVSS_BASE_VECTOR", "CVSS_BASE", "ADVISORY_XREF", "DESCRIPTION", "INSIGHT", "AFFECTED", "CVE_LIST", "BINARY_PACKAGES_FOR_RELEASES", "XREFS", ] self.assertFalse(notus._check_field_names_lsc(field_names_list))