Code Duplication    Length = 21-21 lines in 2 locations

tests/unit/test_main.py 2 locations

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