Code Duplication    Length = 18-29 lines in 2 locations

tests/test_preferencehandler.py 2 locations

@@ 490-518 (lines=29) @@
487
488
        p.kbdb.add_scan_preferences.assert_not_called()
489
490
    @patch('ospd_openvas.db.KbDB')
491
    def test_set_alive_pinghost(self, mock_kb):
492
        w = DummyDaemon()
493
494
        alive_test_out = [
495
            "1.3.6.1.4.1.25623.1.0.100315:1:checkbox:Do a TCP ping|||no",
496
            "1.3.6.1.4.1.25623.1.0.100315:2:checkbox:TCP ping tries also TCP-SYN ping|||no",
497
            "1.3.6.1.4.1.25623.1.0.100315:7:checkbox:TCP ping tries only TCP-SYN ping|||no",
498
            "1.3.6.1.4.1.25623.1.0.100315:3:checkbox:Do an ICMP ping|||yes",
499
            "1.3.6.1.4.1.25623.1.0.100315:4:checkbox:Use ARP|||no",
500
            "1.3.6.1.4.1.25623.1.0.100315:5:checkbox:Mark unrechable Hosts as dead (not scanning)|||yes",
501
        ]
502
503
        t_opt = {'alive_test': 2}
504
        w.scan_collection.get_target_options = MagicMock(return_value=t_opt)
505
506
        ov_setting = {'some_setiting': 1}
507
        Openvas.get_settings = Mock()
508
        Openvas.get_settings.reprepare_mock()
509
        Openvas.get_settings.return_value = ov_setting
510
511
        p = PreferenceHandler('1234-1234', mock_kb, w.scan_collection, None)
512
513
        p._openvas_scan_id = '456-789'
514
        p.kbdb.add_scan_preferences = MagicMock()
515
        p.prepare_alive_test_option_for_openvas()
516
517
        p.kbdb.add_scan_preferences.assert_called_with(
518
            p._openvas_scan_id, alive_test_out,
519
        )
520
@@ 452-469 (lines=18) @@
449
            ['reverse_lookup_only|||yes', 'reverse_lookup_unify|||no',],
450
        )
451
452
    @patch('ospd_openvas.db.KbDB')
453
    def test_set_alive_only(self, mock_kb):
454
        w = DummyDaemon()
455
456
        t_opt = {'alive_test': 16}
457
        w.scan_collection.get_target_options = MagicMock(return_value=t_opt)
458
459
        ov_setting = {'test_alive_hosts_only': 'yes'}
460
461
        Openvas.get_settings = MagicMock(return_value=ov_setting)
462
463
        p = PreferenceHandler('1234-1234', mock_kb, w.scan_collection, None)
464
        p._openvas_scan_id = '456-789'
465
        p.kbdb.add_scan_preferences = MagicMock()
466
        p.prepare_alive_test_option_for_openvas()
467
468
        p.kbdb.add_scan_preferences.assert_called_with(
469
            p._openvas_scan_id, ['ALIVE_TEST|||16'],
470
        )
471
472
    @patch('ospd_openvas.db.KbDB')