Code Duplication    Length = 22-22 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 645-666 (lines=22) @@
642
        self.assertEqual(response.status_code, 404, response.data)
643
        self.assertEqual(mock_switch.enable.call_count, 0)
644
645
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
646
    def test_disable_switch(self, mock_notify_topo):
647
        """Test disable_switch."""
648
        dpid = "00:00:00:00:00:00:00:01"
649
        mock_switch = get_switch_mock(dpid)
650
        self.napp.controller.switches = {dpid: mock_switch}
651
        api = get_test_client(self.napp.controller, self.napp)
652
653
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
654
        response = api.post(url)
655
        self.assertEqual(response.status_code, 201, response.data)
656
        self.assertEqual(mock_switch.disable.call_count, 1)
657
        self.napp.topo_controller.disable_switch.assert_called_once_with(dpid)
658
        mock_notify_topo.assert_called()
659
660
        # fail case
661
        mock_switch.disable.call_count = 0
662
        dpid = "00:00:00:00:00:00:00:02"
663
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
664
        response = api.post(url)
665
        self.assertEqual(response.status_code, 404, response.data)
666
        self.assertEqual(mock_switch.disable.call_count, 0)
667
668
    def test_get_switch_metadata(self):
669
        """Test get_switch_metadata."""
@@ 622-643 (lines=22) @@
619
        with self.assertRaises(RestoreError):
620
            self.napp._load_link(link_attrs_fail)
621
622
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
623
    def test_enable_switch(self, mock_notify_topo):
624
        """Test enable_switch."""
625
        dpid = "00:00:00:00:00:00:00:01"
626
        mock_switch = get_switch_mock(dpid)
627
        self.napp.controller.switches = {dpid: mock_switch}
628
        api = get_test_client(self.napp.controller, self.napp)
629
630
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
631
        response = api.post(url)
632
        self.assertEqual(response.status_code, 201, response.data)
633
        self.assertEqual(mock_switch.enable.call_count, 1)
634
        self.napp.topo_controller.enable_switch.assert_called_once_with(dpid)
635
        mock_notify_topo.assert_called()
636
637
        # fail case
638
        mock_switch.enable.call_count = 0
639
        dpid = "00:00:00:00:00:00:00:02"
640
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
641
        response = api.post(url)
642
        self.assertEqual(response.status_code, 404, response.data)
643
        self.assertEqual(mock_switch.enable.call_count, 0)
644
645
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
646
    def test_disable_switch(self, mock_notify_topo):