Code Duplication    Length = 22-22 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 616-637 (lines=22) @@
613
        self.assertEqual(response.status_code, 404, response.data)
614
        self.assertEqual(mock_switch.enable.call_count, 0)
615
616
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
617
    def test_disable_switch(self, mock_notify_topo):
618
        """Test disable_switch."""
619
        dpid = "00:00:00:00:00:00:00:01"
620
        mock_switch = get_switch_mock(dpid)
621
        self.napp.controller.switches = {dpid: mock_switch}
622
        api = get_test_client(self.napp.controller, self.napp)
623
624
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
625
        response = api.post(url)
626
        self.assertEqual(response.status_code, 201, response.data)
627
        self.assertEqual(mock_switch.disable.call_count, 1)
628
        self.napp.topo_controller.disable_switch.assert_called_once_with(dpid)
629
        mock_notify_topo.assert_called()
630
631
        # fail case
632
        mock_switch.disable.call_count = 0
633
        dpid = "00:00:00:00:00:00:00:02"
634
        url = f'{self.server_name_url}/v3/switches/{dpid}/disable'
635
        response = api.post(url)
636
        self.assertEqual(response.status_code, 404, response.data)
637
        self.assertEqual(mock_switch.disable.call_count, 0)
638
639
    def test_get_switch_metadata(self):
640
        """Test get_switch_metadata."""
@@ 593-614 (lines=22) @@
590
        with self.assertRaises(RestoreError):
591
            self.napp._load_link(link_attrs_fail)
592
593
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
594
    def test_enable_switch(self, mock_notify_topo):
595
        """Test enable_switch."""
596
        dpid = "00:00:00:00:00:00:00:01"
597
        mock_switch = get_switch_mock(dpid)
598
        self.napp.controller.switches = {dpid: mock_switch}
599
        api = get_test_client(self.napp.controller, self.napp)
600
601
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
602
        response = api.post(url)
603
        self.assertEqual(response.status_code, 201, response.data)
604
        self.assertEqual(mock_switch.enable.call_count, 1)
605
        self.napp.topo_controller.enable_switch.assert_called_once_with(dpid)
606
        mock_notify_topo.assert_called()
607
608
        # fail case
609
        mock_switch.enable.call_count = 0
610
        dpid = "00:00:00:00:00:00:00:02"
611
        url = f'{self.server_name_url}/v3/switches/{dpid}/enable'
612
        response = api.post(url)
613
        self.assertEqual(response.status_code, 404, response.data)
614
        self.assertEqual(mock_switch.enable.call_count, 0)
615
616
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
617
    def test_disable_switch(self, mock_notify_topo):