Code Duplication    Length = 22-22 lines in 2 locations

tests/unit/test_main.py 2 locations

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