Code Duplication    Length = 21-21 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 570-590 (lines=21) @@
567
        self.assertEqual(response.status_code, 404, response.data)
568
        self.assertEqual(mock_switch.enable.call_count, 0)
569
570
    @patch('napps.kytos.topology.main.Main.save_status_on_storehouse')
571
    def test_disable_switch(self, mock_save_status):
572
        """Test disable_switch."""
573
        dpid = "00:00:00:00:00:00:00:01"
574
        mock_switch = get_switch_mock(dpid)
575
        self.napp.controller.switches = {dpid: mock_switch}
576
        api = get_test_client(self.napp.controller, self.napp)
577
578
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
579
        response = api.post(url)
580
        self.assertEqual(response.status_code, 201, response.data)
581
        self.assertEqual(mock_switch.disable.call_count, 1)
582
        mock_save_status.assert_called()
583
584
        # fail case
585
        mock_switch.disable.call_count = 0
586
        dpid = "00:00:00:00:00:00:00:02"
587
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
588
        response = api.post(url)
589
        self.assertEqual(response.status_code, 404, response.data)
590
        self.assertEqual(mock_switch.disable.call_count, 0)
591
592
    def test_get_switch_metadata(self):
593
        """Test get_switch_metadata."""
@@ 548-568 (lines=21) @@
545
        with self.assertRaises(RestoreError):
546
            self.napp._load_link(link_attrs_fail)
547
548
    @patch('napps.kytos.topology.main.Main.save_status_on_storehouse')
549
    def test_enable_switch(self, mock_save_status):
550
        """Test enable_switch."""
551
        dpid = "00:00:00:00:00:00:00:01"
552
        mock_switch = get_switch_mock(dpid)
553
        self.napp.controller.switches = {dpid: mock_switch}
554
        api = get_test_client(self.napp.controller, self.napp)
555
556
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
557
        response = api.post(url)
558
        self.assertEqual(response.status_code, 201, response.data)
559
        self.assertEqual(mock_switch.enable.call_count, 1)
560
        mock_save_status.assert_called()
561
562
        # fail case
563
        mock_switch.enable.call_count = 0
564
        dpid = "00:00:00:00:00:00:00:02"
565
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
566
        response = api.post(url)
567
        self.assertEqual(response.status_code, 404, response.data)
568
        self.assertEqual(mock_switch.enable.call_count, 0)
569
570
    @patch('napps.kytos.topology.main.Main.save_status_on_storehouse')
571
    def test_disable_switch(self, mock_save_status):