Code Duplication    Length = 29-33 lines in 2 locations

tests/command/test_commands.py 2 locations

@@ 236-268 (lines=33) @@
233
        with self.assertRaises(OspdError):
234
            cmd.handle_xml(request)
235
236
    @patch("ospd.ospd.create_process")
237
    def test_scan_with_vts_and_param(self, mock_create_process):
238
        daemon = DummyWrapper([])
239
        cmd = StartScan(daemon)
240
241
        # No error
242
        request = et.fromstring(
243
            '<start_scan>'
244
            '<targets>'
245
            '<target>'
246
            '<hosts>localhost</hosts>'
247
            '<ports>80, 443</ports>'
248
            '</target>'
249
            '</targets>'
250
            '<scanner_params />'
251
            '<vt_selection>'
252
            '<vt_single id="1234">'
253
            '<vt_value id="ABC">200</vt_value>'
254
            '</vt_single>'
255
            '</vt_selection>'
256
            '</start_scan>'
257
        )
258
        response = et.fromstring(cmd.handle_xml(request))
259
        daemon.start_queued_scans()
260
261
        scan_id = response.findtext('id')
262
263
        self.assertEqual(
264
            daemon.get_scan_vts(scan_id),
265
            {'1234': {'ABC': '200'}, 'vt_groups': []},
266
        )
267
        daemon.start_queued_scans()
268
        assert_called(mock_create_process)
269
270
    def test_scan_with_vts_and_param_missing_vt_group_filter(self):
271
        daemon = DummyWrapper([])
@@ 292-320 (lines=29) @@
289
        with self.assertRaises(OspdError):
290
            cmd.handle_xml(request)
291
292
    @patch("ospd.ospd.create_process")
293
    def test_scan_with_vts_and_param_with_vt_group_filter(
294
        self, mock_create_process
295
    ):
296
        daemon = DummyWrapper([])
297
        cmd = StartScan(daemon)
298
299
        # No error
300
        request = et.fromstring(
301
            '<start_scan>'
302
            '<targets>'
303
            '<target>'
304
            '<hosts>localhost</hosts>'
305
            '<ports>80, 443</ports>'
306
            '</target>'
307
            '</targets>'
308
            '<scanner_params />'
309
            '<vt_selection>'
310
            '<vt_group filter="a"/>'
311
            '</vt_selection>'
312
            '</start_scan>'
313
        )
314
        response = et.fromstring(cmd.handle_xml(request))
315
        daemon.start_queued_scans()
316
        scan_id = response.findtext('id')
317
318
        self.assertEqual(daemon.get_scan_vts(scan_id), {'vt_groups': ['a']})
319
320
        assert_called(mock_create_process)
321
322
    @patch("ospd.ospd.create_process")
323
    @patch("ospd.command.command.logger")