Code Duplication    Length = 23-23 lines in 2 locations

tests/unit/test_main.py 2 locations

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