|
| 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 | +import testtools |
| 16 | + |
| 17 | +from functional.common import test |
| 18 | + |
| 19 | + |
| 20 | +class SubnetTests(test.TestCase): |
| 21 | + """Functional tests for subnet. """ |
| 22 | + NAME = uuid.uuid4().hex |
| 23 | + NETWORK_NAME = uuid.uuid4().hex |
| 24 | + HEADERS = ['Name'] |
| 25 | + FIELDS = ['name'] |
| 26 | + |
| 27 | + @classmethod |
| 28 | + def setUpClass(cls): |
| 29 | + # Create a network for the subnet. |
| 30 | + cls.openstack('network create ' + cls.NETWORK_NAME) |
| 31 | + opts = cls.get_show_opts(cls.FIELDS) |
| 32 | + raw_output = cls.openstack( |
| 33 | + 'subnet create --network ' + cls.NETWORK_NAME + |
| 34 | + ' --subnet-range 10.10.10.0/24 ' + |
| 35 | + cls.NAME + opts |
| 36 | + ) |
| 37 | + expected = cls.NAME + '\n' |
| 38 | + cls.assertOutput(expected, raw_output) |
| 39 | + |
| 40 | + @classmethod |
| 41 | + def tearDownClass(cls): |
| 42 | + raw_output = cls.openstack('subnet delete ' + cls.NAME) |
| 43 | + cls.assertOutput('', raw_output) |
| 44 | + raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME) |
| 45 | + cls.assertOutput('', raw_output) |
| 46 | + |
| 47 | + def test_subnet_list(self): |
| 48 | + opts = self.get_list_opts(self.HEADERS) |
| 49 | + raw_output = self.openstack('subnet list' + opts) |
| 50 | + self.assertIn(self.NAME, raw_output) |
| 51 | + |
| 52 | + @testtools.skip('bug/1542363') |
| 53 | + def test_subnet_set(self): |
| 54 | + self.openstack('subnet set --no-dhcp ' + self.NAME) |
| 55 | + opts = self.get_show_opts(['name', 'enable_dhcp']) |
| 56 | + raw_output = self.openstack('subnet show ' + self.NAME + opts) |
| 57 | + self.assertEqual("False\n" + self.NAME + "\n", raw_output) |
| 58 | + |
| 59 | + def test_subnet_show(self): |
| 60 | + opts = self.get_show_opts(self.FIELDS) |
| 61 | + raw_output = self.openstack('subnet show ' + self.NAME + opts) |
| 62 | + self.assertEqual(self.NAME + "\n", raw_output) |
0 commit comments