Code Duplication    Length = 19-19 lines in 3 locations

tests/test_preferencehandler.py 3 locations

@@ 1244-1262 (lines=19) @@
1241
                alive_test_out,
1242
            )
1243
1244
    @patch('ospd_openvas.db.KbDB')
1245
    def test_prepare_alive_test_no_enum_no_alive_test(self, mock_kb):
1246
        dummy = DummyDaemon()
1247
1248
        t_opt = {'alive_test_methods': '1', 'icmp': '0'}
1249
        dummy.scan_collection.get_target_options = MagicMock(return_value=t_opt)
1250
1251
        ov_setting = {'some_setting': 1}
1252
1253
        with patch.object(Openvas, 'get_settings', return_value=ov_setting):
1254
            p_handler = PreferenceHandler(
1255
                '1234-1234', mock_kb, dummy.scan_collection, None
1256
            )
1257
            p_handler._nvts_params = {}  # pylint: disable = protected-access
1258
            p_handler.scan_id = '456-789'
1259
            p_handler.kbdb.add_scan_preferences = MagicMock()
1260
            p_handler.prepare_alive_test_option_for_openvas()
1261
1262
            p_handler.kbdb.add_scan_preferences.assert_not_called()
1263
1264
    def test_alive_test_methods_to_bit_field(self):
1265
@@ 1149-1167 (lines=19) @@
1146
1147
            p_handler.kbdb.add_scan_preferences.assert_not_called()
1148
1149
    @patch('ospd_openvas.db.KbDB')
1150
    def test_set_alive_no_invalid_alive_test_no_enum(self, mock_kb):
1151
        dummy = DummyDaemon()
1152
1153
        t_opt = {'alive_test_methods': '1', 'icmp': '-1'}
1154
        dummy.scan_collection.get_target_options = MagicMock(return_value=t_opt)
1155
1156
        ov_setting = {'some_setting': 1}
1157
1158
        with patch.object(Openvas, 'get_settings', return_value=ov_setting):
1159
            p_handler = PreferenceHandler(
1160
                '1234-1234', mock_kb, dummy.scan_collection, None
1161
            )
1162
            p_handler._nvts_params = {}  # pylint: disable = protected-access
1163
            p_handler.scan_id = '456-789'
1164
            p_handler.kbdb.add_scan_preferences = MagicMock()
1165
            p_handler.prepare_alive_test_option_for_openvas()
1166
1167
            p_handler.kbdb.add_scan_preferences.assert_not_called()
1168
1169
    @patch('ospd_openvas.db.KbDB')
1170
    def test_set_alive_pinghost(self, mock_kb):
@@ 1129-1147 (lines=19) @@
1126
1127
            p_handler.kbdb.add_scan_preferences.assert_not_called()
1128
1129
    @patch('ospd_openvas.db.KbDB')
1130
    def test_set_alive_no_invalid_alive_test(self, mock_kb):
1131
        dummy = DummyDaemon()
1132
1133
        t_opt = {'alive_test': -1}
1134
        dummy.scan_collection.get_target_options = MagicMock(return_value=t_opt)
1135
1136
        ov_setting = {'some_setting': 1}
1137
1138
        with patch.object(Openvas, 'get_settings', return_value=ov_setting):
1139
            p_handler = PreferenceHandler(
1140
                '1234-1234', mock_kb, dummy.scan_collection, None
1141
            )
1142
            p_handler._nvts_params = {}  # pylint: disable = protected-access
1143
            p_handler.scan_id = '456-789'
1144
            p_handler.kbdb.add_scan_preferences = MagicMock()
1145
            p_handler.prepare_alive_test_option_for_openvas()
1146
1147
            p_handler.kbdb.add_scan_preferences.assert_not_called()
1148
1149
    @patch('ospd_openvas.db.KbDB')
1150
    def test_set_alive_no_invalid_alive_test_no_enum(self, mock_kb):