diff options
| author | Reedip <reedip14@gmail.com> | 2017-02-23 08:05:00 -0500 |
|---|---|---|
| committer | Reedip <reedip.banerjee@gmail.com> | 2017-06-12 02:52:28 +0000 |
| commit | eb793dc8c6a8bd30e612f19f30808528b10eb344 (patch) | |
| tree | 3b4850912510b0c24258bdb2539b8892f1d2d6c1 /openstackclient/tests | |
| parent | e54fcd0a5ccb80b56db3b61ae461473f2ceddea9 (diff) | |
| download | python-openstackclient-eb793dc8c6a8bd30e612f19f30808528b10eb344.tar.gz | |
Add default-quota to subnet pool commands
Add --default-quota option to subnet pool create and set commands.
Setting default-quota back to None may break the current Neutron
behavior, therefore support for Unset command is not provided in
this patch.
Neutron API:
https://github.com/openstack/neutron/blob/a0e0e8b6686b847a4963a6aa6a3224b5768544e6/neutron/api/v2/attributes.py#L239
Closes-Bug: #1667294
Change-Id: Ia4e7c23a49e91a090133c729353cdb8e62bc5674
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/functional/network/v2/test_subnet_pool.py | 39 | ||||
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_subnet_pool.py | 42 |
2 files changed, 76 insertions, 5 deletions
diff --git a/openstackclient/tests/functional/network/v2/test_subnet_pool.py b/openstackclient/tests/functional/network/v2/test_subnet_pool.py index 640f68b7..a4b823f1 100644 --- a/openstackclient/tests/functional/network/v2/test_subnet_pool.py +++ b/openstackclient/tests/functional/network/v2/test_subnet_pool.py @@ -165,7 +165,7 @@ class SubnetPoolTests(common.NetworkTests): self.assertIn(name2, names) def test_subnet_pool_set_show(self): - """Test create, set, show, delete""" + """Test create, delete, set, show, unset""" name = uuid.uuid4().hex new_name = name + "_" @@ -173,11 +173,15 @@ class SubnetPoolTests(common.NetworkTests): '--default-prefix-length 16 ' + '--min-prefix-length 16 ' + '--max-prefix-length 32 ' + - '--description aaaa ', + '--description aaaa ' + + '--default-quota 10 ', name, ) - self.addCleanup(self.openstack, 'subnet pool delete ' + new_name) + self.addCleanup( + self.openstack, + 'subnet pool delete ' + cmd_output['id'], + ) self.assertEqual( name, cmd_output["name"], @@ -202,6 +206,10 @@ class SubnetPoolTests(common.NetworkTests): 32, cmd_output["max_prefixlen"], ) + self.assertEqual( + 10, + cmd_output["default_quota"], + ) # Test set cmd_output = self.openstack( @@ -212,7 +220,8 @@ class SubnetPoolTests(common.NetworkTests): '--default-prefix-length 8 ' + '--min-prefix-length 8 ' + '--max-prefix-length 16 ' + - name + '--default-quota 20 ' + + name, ) self.assertOutput('', cmd_output) @@ -244,6 +253,28 @@ class SubnetPoolTests(common.NetworkTests): 16, cmd_output["max_prefixlen"], ) + self.assertEqual( + 20, + cmd_output["default_quota"], + ) + + # Test unset + # NOTE(dtroyer): The unset command --default-quota option DOES NOT + # WORK after a default quota has been set once on a + # pool. The error appears to be in a lower layer, + # once that is fixed add a test for subnet pool unset + # --default-quota. + # The unset command of --pool-prefixes also doesnt work + # right now. It would be fixed in a separate patch once + # the lower layer is fixed. + # cmd_output = self.openstack( + # '--debug ' + + # 'subnet pool unset ' + + # ' --pool-prefix 10.110.0.0/16 ' + + # new_name, + # ) + # self.assertOutput('', cmd_output) + # self.assertNone(cmd_output["prefixes"]) def _subnet_pool_create(self, cmd, name, is_type_ipv4=True): """Make a random subnet pool diff --git a/openstackclient/tests/unit/network/v2/test_subnet_pool.py b/openstackclient/tests/unit/network/v2/test_subnet_pool.py index f12537e7..80a57bbb 100644 --- a/openstackclient/tests/unit/network/v2/test_subnet_pool.py +++ b/openstackclient/tests/unit/network/v2/test_subnet_pool.py @@ -270,6 +270,27 @@ class TestCreateSubnetPool(TestSubnetPool): self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) + def test_create_with_default_quota(self): + arglist = [ + '--pool-prefix', '10.0.10.0/24', + '--default-quota', '10', + self._subnet_pool.name, + ] + verifylist = [ + ('prefixes', ['10.0.10.0/24']), + ('default_quota', 10), + ('name', self._subnet_pool.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + columns, data = (self.cmd.take_action(parsed_args)) + self.network.create_subnet_pool.assert_called_once_with(**{ + 'name': self._subnet_pool.name, + 'prefixes': ['10.0.10.0/24'], + 'default_quota': 10, + }) + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, data) + class TestDeleteSubnetPool(TestSubnetPool): @@ -567,7 +588,9 @@ class TestListSubnetPool(TestSubnetPool): class TestSetSubnetPool(TestSubnetPool): # The subnet_pool to set. - _subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool() + _subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool( + {'default_quota': 10}, + ) _address_scope = network_fakes.FakeAddressScope.create_one_address_scope() @@ -794,6 +817,23 @@ class TestSetSubnetPool(TestSubnetPool): self._subnet_pool, **attrs) self.assertIsNone(result) + def test_set_with_default_quota(self): + arglist = [ + '--default-quota', '20', + self._subnet_pool.name, + ] + verifylist = [ + ('default_quota', 20), + ('subnet_pool', self._subnet_pool.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + result = self.cmd.take_action(parsed_args) + self.network.update_subnet_pool.assert_called_once_with( + self._subnet_pool, + **{'default_quota': 20, } + ) + self.assertIsNone(result) + class TestShowSubnetPool(TestSubnetPool): |
