Code Duplication    Length = 16-31 lines in 2 locations

tests/test_preferencehandler.py 2 locations

@@ 236-266 (lines=31) @@
233
        ret = p.build_alive_test_opt_as_prefs(target_options_dict)
234
        self.assertEqual(ret, [])
235
236
    def test_build_alive_test_opt(self):
237
        w = DummyDaemon()
238
239
        alive_test_out = [
240
            "1.3.6.1.4.1.25623.1.0.100315:1:checkbox:Do a TCP ping|||no",
241
            "1.3.6.1.4.1.25623.1.0.100315:2:checkbox:TCP ping tries also TCP-SYN ping|||no",
242
            "1.3.6.1.4.1.25623.1.0.100315:7:checkbox:TCP ping tries only TCP-SYN ping|||no",
243
            "1.3.6.1.4.1.25623.1.0.100315:3:checkbox:Do an ICMP ping|||yes",
244
            "1.3.6.1.4.1.25623.1.0.100315:4:checkbox:Use ARP|||no",
245
            "1.3.6.1.4.1.25623.1.0.100315:5:checkbox:Mark unrechable Hosts as dead (not scanning)|||yes",
246
        ]
247
        target_options_dict = {'alive_test': '2'}
248
        p = PreferenceHandler('1234-1234', None, w.scan_collection, None)
249
        ret = p.build_alive_test_opt_as_prefs(target_options_dict)
250
251
        self.assertEqual(ret, alive_test_out)
252
253
        # alive test was supplied via sepertae xml element
254
        w = DummyDaemon()
255
        alive_test_out = [
256
            "1.3.6.1.4.1.25623.1.0.100315:1:checkbox:Do a TCP ping|||no",
257
            "1.3.6.1.4.1.25623.1.0.100315:2:checkbox:TCP ping tries also TCP-SYN ping|||no",
258
            "1.3.6.1.4.1.25623.1.0.100315:7:checkbox:TCP ping tries only TCP-SYN ping|||no",
259
            "1.3.6.1.4.1.25623.1.0.100315:3:checkbox:Do an ICMP ping|||yes",
260
            "1.3.6.1.4.1.25623.1.0.100315:4:checkbox:Use ARP|||no",
261
            "1.3.6.1.4.1.25623.1.0.100315:5:checkbox:Mark unrechable Hosts as dead (not scanning)|||yes",
262
        ]
263
        target_options_dict = {'alive_test_methods': '1', 'icmp': '1'}
264
        p = PreferenceHandler('1234-1234', None, w.scan_collection, None)
265
        ret = p.build_alive_test_opt_as_prefs(target_options_dict)
266
        self.assertEqual(ret, alive_test_out)
267
268
    def test_build_alive_test_opt_fail_1(self):
269
        w = DummyDaemon()
@@ 219-234 (lines=16) @@
216
            cred_out,
217
        )
218
219
    def test_build_alive_test_opt_empty(self):
220
        w = DummyDaemon()
221
222
        target_options_dict = {'alive_test': '0'}
223
224
        p = PreferenceHandler('1234-1234', None, w.scan_collection, None)
225
        ret = p.build_alive_test_opt_as_prefs(target_options_dict)
226
227
        self.assertEqual(ret, [])
228
229
        # alive test was supplied via seperate xml element
230
        w = DummyDaemon()
231
        target_options_dict = {'alive_test_methods': '1', 'icmp': '0'}
232
        p = PreferenceHandler('1234-1234', None, w.scan_collection, None)
233
        ret = p.build_alive_test_opt_as_prefs(target_options_dict)
234
        self.assertEqual(ret, [])
235
236
    def test_build_alive_test_opt(self):
237
        w = DummyDaemon()