|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | + |
| 13 | +import uuid |
| 14 | + |
| 15 | +from functional.common import test |
| 16 | + |
| 17 | + |
| 18 | +class IPAvailabilityTests(test.TestCase): |
| 19 | + """Functional tests for IP availability. """ |
| 20 | + NAME = uuid.uuid4().hex |
| 21 | + NETWORK_NAME = uuid.uuid4().hex |
| 22 | + FIELDS = ['network_name'] |
| 23 | + |
| 24 | + @classmethod |
| 25 | + def setUpClass(cls): |
| 26 | + # Create a network for the subnet. |
| 27 | + cls.openstack('network create ' + cls.NETWORK_NAME) |
| 28 | + opts = cls.get_show_opts(['name']) |
| 29 | + raw_output = cls.openstack( |
| 30 | + 'subnet create --network ' + cls.NETWORK_NAME + |
| 31 | + ' --subnet-range 10.10.10.0/24 ' + |
| 32 | + cls.NAME + opts |
| 33 | + ) |
| 34 | + expected = cls.NAME + '\n' |
| 35 | + cls.assertOutput(expected, raw_output) |
| 36 | + |
| 37 | + @classmethod |
| 38 | + def tearDownClass(cls): |
| 39 | + raw_subnet = cls.openstack('subnet delete ' + cls.NAME) |
| 40 | + raw_network = cls.openstack('network delete ' + cls.NETWORK_NAME) |
| 41 | + cls.assertOutput('', raw_subnet) |
| 42 | + cls.assertOutput('', raw_network) |
| 43 | + |
| 44 | + def test_ip_availability_list(self): |
| 45 | + opts = ' -f csv -c "Network Name"' |
| 46 | + raw_output = self.openstack('ip availability list' + opts) |
| 47 | + self.assertIn(self.NETWORK_NAME, raw_output) |
| 48 | + |
| 49 | + def test_ip_availability_show(self): |
| 50 | + opts = self.get_show_opts(self.FIELDS) |
| 51 | + raw_output = self.openstack( |
| 52 | + 'ip availability show ' + self.NETWORK_NAME + opts) |
| 53 | + self.assertEqual(self.NETWORK_NAME + "\n", raw_output) |
0 commit comments