Code Duplication    Length = 21-21 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 353-373 (lines=21) @@
350
        self.assertEqual(response.status_code, 404, response.data)
351
        self.assertEqual(mock_switch.enable.call_count, 0)
352
353
    @patch('napps.kytos.topology.main.Main.save_status_on_storehouse')
354
    def test_disable_switch(self, mock_save_status):
355
        """Test disable_switch."""
356
        dpid = "00:00:00:00:00:00:00:01"
357
        mock_switch = get_switch_mock(dpid)
358
        self.napp.controller.switches = {dpid: mock_switch}
359
        api = get_test_client(self.napp.controller, self.napp)
360
361
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
362
        response = api.post(url)
363
        self.assertEqual(response.status_code, 201, response.data)
364
        self.assertEqual(mock_switch.disable.call_count, 1)
365
        mock_save_status.assert_called()
366
367
        # fail case
368
        mock_switch.disable.call_count = 0
369
        dpid = "00:00:00:00:00:00:00:02"
370
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
371
        response = api.post(url)
372
        self.assertEqual(response.status_code, 404, response.data)
373
        self.assertEqual(mock_switch.disable.call_count, 0)
374
375
    def test_get_switch_metadata(self):
376
        """Test get_switch_metadata."""
@@ 331-351 (lines=21) @@
328
            self.napp._restore_switches(dpid_fail)
329
        self.assertRaises(KeyError)
330
331
    @patch('napps.kytos.topology.main.Main.save_status_on_storehouse')
332
    def test_enable_switch(self, mock_save_status):
333
        """Test enable_switch."""
334
        dpid = "00:00:00:00:00:00:00:01"
335
        mock_switch = get_switch_mock(dpid)
336
        self.napp.controller.switches = {dpid: mock_switch}
337
        api = get_test_client(self.napp.controller, self.napp)
338
339
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
340
        response = api.post(url)
341
        self.assertEqual(response.status_code, 201, response.data)
342
        self.assertEqual(mock_switch.enable.call_count, 1)
343
        mock_save_status.assert_called()
344
345
        # fail case
346
        mock_switch.enable.call_count = 0
347
        dpid = "00:00:00:00:00:00:00:02"
348
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
349
        response = api.post(url)
350
        self.assertEqual(response.status_code, 404, response.data)
351
        self.assertEqual(mock_switch.enable.call_count, 0)
352
353
    @patch('napps.kytos.topology.main.Main.save_status_on_storehouse')
354
    def test_disable_switch(self, mock_save_status):