Code Duplication    Length = 28-28 lines in 2 locations

tests/notus/test_notus.py 2 locations

@@ 402-429 (lines=28) @@
399
            "Loaded %d/%d advisories from %s", 0, 1, purepath
400
        )
401
402
    def test_upload_lsc_from_csv_reader_sucess(self):
403
        general_metadata_dict = {
404
            'VULDETECT': 'Checks if a vulnerable package version is present on the target host.',
405
            'SOLUTION': 'Please install the updated package(s).',
406
            'SOLUTION_TYPE': 'VendorFix',
407
            'QOD_TYPE': 'package',
408
        }
409
410
        notus = NotusMetadataHandler(
411
            nvti=self.nvti, metadata_path="./tests/notus"
412
        )
413
        notus.nvti.add_vt_to_cache.return_value = None
414
        logging.Logger.debug = MagicMock()
415
        path = Path("./tests/notus/example.csv").resolve()
416
        purepath = PurePath(path).name
417
        with path.open("r") as openfile:
418
            for line_string in openfile:
419
                if line_string.startswith("{"):
420
                    break
421
            reader = DictReader(openfile)
422
423
            ret = notus.upload_lsc_from_csv_reader(
424
                purepath, general_metadata_dict, reader
425
            )
426
427
        self.assertTrue(ret)
428
        logging.Logger.debug.assert_called_with(
429
            "Loaded %d/%d advisories from %s", 1, 1, purepath
430
        )
431
@@ 372-399 (lines=28) @@
369
370
        logging.Logger.warning.assert_not_called()
371
372
    def test_upload_lsc_from_csv_reader_failed(self):
373
        general_metadata_dict = {
374
            'VULDETECT': 'Checks if a vulnerable package version is present on the target host.',
375
            'SOLUTION': 'Please install the updated package(s).',
376
            'SOLUTION_TYPE': 'VendorFix',
377
            'QOD_TYPE': 'package',
378
        }
379
380
        notus = NotusMetadataHandler(
381
            nvti=self.nvti, metadata_path="./tests/notus"
382
        )
383
        notus.nvti.add_vt_to_cache.side_effect = OspdOpenvasError
384
        logging.Logger.debug = MagicMock()
385
        path = Path("./tests/notus/example.csv").resolve()
386
        purepath = PurePath(path).name
387
        with path.open("r") as openfile:
388
            for line_string in openfile:
389
                if line_string.startswith("{"):
390
                    break
391
            reader = DictReader(openfile)
392
393
            ret = notus.upload_lsc_from_csv_reader(
394
                purepath, general_metadata_dict, reader
395
            )
396
397
        self.assertFalse(ret)
398
        logging.Logger.debug.assert_called_with(
399
            "Loaded %d/%d advisories from %s", 0, 1, purepath
400
        )
401
402
    def test_upload_lsc_from_csv_reader_sucess(self):