Code Duplication    Length = 23-23 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 598-620 (lines=23) @@
595
        assert response.status_code == 404
596
        assert mock_switch.enable.call_count == 0
597
598
    @patch('napps.kytos.topology.main.Main.notify_switch_links_status')
599
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
600
    async def test_disable_switch(self, mock_notify_topo, mock_sw_l_status):
601
        """Test disable_switch."""
602
        dpid = "00:00:00:00:00:00:00:01"
603
        mock_switch = get_switch_mock(dpid)
604
        self.napp.controller.switches = {dpid: mock_switch}
605
606
        endpoint = f"{self.base_endpoint}/switches/{dpid}/disable"
607
        response = await self.api_client.post(endpoint)
608
        assert response.status_code == 201
609
        assert mock_switch.disable.call_count == 1
610
        self.napp.topo_controller.disable_switch.assert_called_once_with(dpid)
611
        mock_notify_topo.assert_called()
612
        mock_sw_l_status.assert_called()
613
614
        # fail case
615
        mock_switch.disable.call_count = 0
616
        dpid = "00:00:00:00:00:00:00:02"
617
        endpoint = f"{self.base_endpoint}/switches/{dpid}/disable"
618
        response = await self.api_client.post(endpoint)
619
        assert response.status_code == 404
620
        assert mock_switch.disable.call_count == 0
621
622
    async def test_get_switch_metadata(self):
623
        """Test get_switch_metadata."""
@@ 574-596 (lines=23) @@
571
        with pytest.raises(RestoreError):
572
            self.napp._load_link(link_attrs_fail)
573
574
    @patch('napps.kytos.topology.main.Main.notify_switch_links_status')
575
    @patch('napps.kytos.topology.main.Main.notify_topology_update')
576
    async def test_enable_switch(self, mock_notify_topo, mock_sw_l_status):
577
        """Test enable_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
582
        endpoint = f"{self.base_endpoint}/switches/{dpid}/enable"
583
        response = await self.api_client.post(endpoint)
584
        assert response.status_code == 201
585
        assert mock_switch.enable.call_count == 1
586
        self.napp.topo_controller.enable_switch.assert_called_once_with(dpid)
587
        mock_notify_topo.assert_called()
588
        mock_sw_l_status.assert_called()
589
590
        # fail case
591
        mock_switch.enable.call_count = 0
592
        dpid = "00:00:00:00:00:00:00:02"
593
        endpoint = f"{self.base_endpoint}/switches/{dpid}/enable"
594
        response = await self.api_client.post(endpoint)
595
        assert response.status_code == 404
596
        assert mock_switch.enable.call_count == 0
597
598
    @patch('napps.kytos.topology.main.Main.notify_switch_links_status')
599
    @patch('napps.kytos.topology.main.Main.notify_topology_update')