@@ 1827-1852 (lines=26) @@ | ||
1824 | assert response.status_code == 200 |
|
1825 | assert response.json() == expected |
|
1826 | ||
1827 | async def test_get_tag_ranges_by_intf(self): |
|
1828 | """Test get_tag_ranges_by_intf""" |
|
1829 | self.napp.controller.loop = asyncio.get_running_loop() |
|
1830 | dpid = '00:00:00:00:00:00:00:01' |
|
1831 | switch = get_switch_mock(dpid) |
|
1832 | interface = get_interface_mock('s1-eth1', 1, switch) |
|
1833 | tags = {'vlan': [[1, 4095]]} |
|
1834 | special_tags = {'vlan': ["vlan"]} |
|
1835 | interface.tag_ranges = tags |
|
1836 | interface.available_tags = tags |
|
1837 | interface.special_available_tags = special_tags |
|
1838 | interface.special_tags = special_tags |
|
1839 | self.napp.controller.get_interface_by_id = MagicMock() |
|
1840 | self.napp.controller.get_interface_by_id.return_value = interface |
|
1841 | url = f"{self.base_endpoint}/interfaces/{dpid}:1/tag_ranges" |
|
1842 | response = await self.api_client.get(url) |
|
1843 | expected = { |
|
1844 | '00:00:00:00:00:00:00:01:1': { |
|
1845 | "available_tags": tags, |
|
1846 | "tag_ranges": tags, |
|
1847 | 'special_available_tags': special_tags, |
|
1848 | 'special_tags': special_tags |
|
1849 | } |
|
1850 | } |
|
1851 | assert response.status_code == 200 |
|
1852 | assert response.json() == expected |
|
1853 | ||
1854 | async def test_get_tag_ranges_by_intf_error(self): |
|
1855 | """Test get_tag_ranges_by_intf with NotFound""" |
|
@@ 1802-1825 (lines=24) @@ | ||
1799 | response = await self.api_client.delete(url) |
|
1800 | assert response.status_code == 400 |
|
1801 | ||
1802 | async def test_get_all_tag_ranges(self): |
|
1803 | """Test get_all_tag_ranges""" |
|
1804 | self.napp.controller.loop = asyncio.get_running_loop() |
|
1805 | dpid = '00:00:00:00:00:00:00:01' |
|
1806 | switch = get_switch_mock(dpid) |
|
1807 | interface = get_interface_mock('s1-eth1', 1, switch) |
|
1808 | tags = {'vlan': [[1, 4095]]} |
|
1809 | special_tags = {'vlan': ["vlan"]} |
|
1810 | interface.tag_ranges = tags |
|
1811 | interface.available_tags = tags |
|
1812 | interface.special_available_tags = special_tags |
|
1813 | interface.special_tags = special_tags |
|
1814 | switch.interfaces = {1: interface} |
|
1815 | self.napp.controller.switches = {dpid: switch} |
|
1816 | url = f"{self.base_endpoint}/interfaces/tag_ranges" |
|
1817 | response = await self.api_client.get(url) |
|
1818 | expected = {dpid + ":1": { |
|
1819 | 'available_tags': tags, |
|
1820 | 'tag_ranges': tags, |
|
1821 | 'special_available_tags': special_tags, |
|
1822 | 'special_tags': special_tags |
|
1823 | }} |
|
1824 | assert response.status_code == 200 |
|
1825 | assert response.json() == expected |
|
1826 | ||
1827 | async def test_get_tag_ranges_by_intf(self): |
|
1828 | """Test get_tag_ranges_by_intf""" |