Code Duplication    Length = 21-21 lines in 2 locations

tests/unit/test_main.py 2 locations

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