Code Duplication    Length = 23-23 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 583-605 (lines=23) @@
580
        assert response.status_code == 404
581
        assert mock_switch.enable.call_count == 0
582
583
    @patch('napps.kytos.topology.main.Main.notify_switch_links_status')
584
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
585
    async def test_disable_switch(self, mock_notify_topo, mock_sw_l_status):
586
        """Test disable_switch."""
587
        dpid = "00:00:00:00:00:00:00:01"
588
        mock_switch = get_switch_mock(dpid)
589
        self.napp.controller.switches = {dpid: mock_switch}
590
591
        endpoint = f"{self.base_endpoint}/switches/{dpid}/disable"
592
        response = await self.api_client.post(endpoint)
593
        assert response.status_code == 201
594
        assert mock_switch.disable.call_count == 1
595
        self.napp.topo_controller.disable_switch.assert_called_once_with(dpid)
596
        mock_notify_topo.assert_called()
597
        mock_sw_l_status.assert_called()
598
599
        # fail case
600
        mock_switch.disable.call_count = 0
601
        dpid = "00:00:00:00:00:00:00:02"
602
        endpoint = f"{self.base_endpoint}/switches/{dpid}/disable"
603
        response = await self.api_client.post(endpoint)
604
        assert response.status_code == 404
605
        assert mock_switch.disable.call_count == 0
606
607
    async def test_get_switch_metadata(self):
608
        """Test get_switch_metadata."""
@@ 559-581 (lines=23) @@
556
        with pytest.raises(RestoreError):
557
            self.napp._load_link(link_attrs_fail)
558
559
    @patch('napps.kytos.topology.main.Main.notify_switch_links_status')
560
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
561
    async def test_enable_switch(self, mock_notify_topo, mock_sw_l_status):
562
        """Test enable_switch."""
563
        dpid = "00:00:00:00:00:00:00:01"
564
        mock_switch = get_switch_mock(dpid)
565
        self.napp.controller.switches = {dpid: mock_switch}
566
567
        endpoint = f"{self.base_endpoint}/switches/{dpid}/enable"
568
        response = await self.api_client.post(endpoint)
569
        assert response.status_code == 201
570
        assert mock_switch.enable.call_count == 1
571
        self.napp.topo_controller.enable_switch.assert_called_once_with(dpid)
572
        mock_notify_topo.assert_called()
573
        mock_sw_l_status.assert_called()
574
575
        # fail case
576
        mock_switch.enable.call_count = 0
577
        dpid = "00:00:00:00:00:00:00:02"
578
        endpoint = f"{self.base_endpoint}/switches/{dpid}/enable"
579
        response = await self.api_client.post(endpoint)
580
        assert response.status_code == 404
581
        assert mock_switch.enable.call_count == 0
582
583
    @patch('napps.kytos.topology.main.Main.notify_switch_links_status')
584
    @patch('napps.kytos.topology.main.Main.notify_topology_update')