Code Duplication    Length = 28-28 lines in 2 locations

tests/notus/test_notus.py 2 locations

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