Code Duplication    Length = 23-23 lines in 2 locations

tests/unit/test_main.py 2 locations

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