Code Duplication    Length = 24-26 lines in 2 locations

tests/unit/test_main.py 2 locations

@@ 1873-1898 (lines=26) @@
1870
        assert response.status_code == 200
1871
        assert response.json() == expected
1872
1873
    async def test_get_tag_ranges_by_intf(self):
1874
        """Test get_tag_ranges_by_intf"""
1875
        self.napp.controller.loop = asyncio.get_running_loop()
1876
        dpid = '00:00:00:00:00:00:00:01'
1877
        switch = get_switch_mock(dpid)
1878
        interface = get_interface_mock('s1-eth1', 1, switch)
1879
        tags = {'vlan': [[1, 4095]]}
1880
        special_tags = {'vlan': ["vlan"]}
1881
        interface.tag_ranges = tags
1882
        interface.available_tags = tags
1883
        interface.special_available_tags = special_tags
1884
        interface.special_tags = special_tags
1885
        self.napp.controller.get_interface_by_id = MagicMock()
1886
        self.napp.controller.get_interface_by_id.return_value = interface
1887
        url = f"{self.base_endpoint}/interfaces/{dpid}:1/tag_ranges"
1888
        response = await self.api_client.get(url)
1889
        expected = {
1890
            '00:00:00:00:00:00:00:01:1': {
1891
                "available_tags": tags,
1892
                "tag_ranges": tags,
1893
                'special_available_tags': special_tags,
1894
                'special_tags': special_tags
1895
            }
1896
        }
1897
        assert response.status_code == 200
1898
        assert response.json() == expected
1899
1900
    async def test_get_tag_ranges_by_intf_error(self):
1901
        """Test get_tag_ranges_by_intf with NotFound"""
@@ 1848-1871 (lines=24) @@
1845
        response = await self.api_client.delete(url)
1846
        assert response.status_code == 400
1847
1848
    async def test_get_all_tag_ranges(self):
1849
        """Test get_all_tag_ranges"""
1850
        self.napp.controller.loop = asyncio.get_running_loop()
1851
        dpid = '00:00:00:00:00:00:00:01'
1852
        switch = get_switch_mock(dpid)
1853
        interface = get_interface_mock('s1-eth1', 1, switch)
1854
        tags = {'vlan': [[1, 4095]]}
1855
        special_tags = {'vlan': ["vlan"]}
1856
        interface.tag_ranges = tags
1857
        interface.available_tags = tags
1858
        interface.special_available_tags = special_tags
1859
        interface.special_tags = special_tags
1860
        switch.interfaces = {1: interface}
1861
        self.napp.controller.switches = {dpid: switch}
1862
        url = f"{self.base_endpoint}/interfaces/tag_ranges"
1863
        response = await self.api_client.get(url)
1864
        expected = {dpid + ":1": {
1865
            'available_tags': tags,
1866
            'tag_ranges': tags,
1867
            'special_available_tags': special_tags,
1868
            'special_tags': special_tags
1869
        }}
1870
        assert response.status_code == 200
1871
        assert response.json() == expected
1872
1873
    async def test_get_tag_ranges_by_intf(self):
1874
        """Test get_tag_ranges_by_intf"""