summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2017-01-15 14:37:49 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2017-01-15 20:00:53 +0800
commit0340275fa9b48cda5a5f4015534ca8cbca23b3d2 (patch)
treeace9fe0de450309fd2ffc15cbd00a4bf267c726f /openstackclient/tests
parentb860ba0e42b942a1a5fb01b55d35a2edf062bf65 (diff)
downloadpython-openstackclient-0340275fa9b48cda5a5f4015534ca8cbca23b3d2.tar.gz
Fix quota set command error for SDK > 0.9.10
A bug in OpenStack SDK 0.9.11 and 0.9.12 that causes quota set command to fail. This can be removed when the proposed SDK fix (https://review.openstack.org/#/c/419911/) is released and in the minimum SDK version in global requirements. Closes-Bug: #1655445 Change-Id: I63132f5f762f0120282f8b92e72512763063e3c6
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/functional/common/test_quota.py3
-rw-r--r--openstackclient/tests/unit/common/test_quota.py72
2 files changed, 42 insertions, 33 deletions
diff --git a/openstackclient/tests/functional/common/test_quota.py b/openstackclient/tests/functional/common/test_quota.py
index b2b198af..c1de9aa9 100644
--- a/openstackclient/tests/functional/common/test_quota.py
+++ b/openstackclient/tests/functional/common/test_quota.py
@@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from openstackclient.tests.functional import base
@@ -27,7 +25,6 @@ class QuotaTests(base.TestCase):
cls.PROJECT_NAME =\
cls.get_openstack_configuration_value('auth.project_name')
- @testtools.skip('broken SDK testing')
def test_quota_set(self):
self.openstack('quota set --instances 11 --volumes 11 --networks 11 ' +
self.PROJECT_NAME)
diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py
index 7dd23373..244d74d2 100644
--- a/openstackclient/tests/unit/common/test_quota.py
+++ b/openstackclient/tests/unit/common/test_quota.py
@@ -13,6 +13,8 @@
import copy
import mock
+from openstack.network.v2 import quota as _quota
+
from openstackclient.common import quota
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
from openstackclient.tests.unit import fakes
@@ -282,27 +284,32 @@ class TestQuotaSet(TestQuota):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- result = self.cmd.take_action(parsed_args)
- kwargs = {
- 'subnet': network_fakes.QUOTA['subnet'],
- 'network': network_fakes.QUOTA['network'],
- 'floatingip': network_fakes.QUOTA['floatingip'],
- 'subnetpool': network_fakes.QUOTA['subnetpool'],
- 'security_group_rule':
- network_fakes.QUOTA['security_group_rule'],
- 'security_group': network_fakes.QUOTA['security_group'],
- 'router': network_fakes.QUOTA['router'],
- 'rbac_policy': network_fakes.QUOTA['rbac_policy'],
- 'port': network_fakes.QUOTA['port'],
- 'vip': network_fakes.QUOTA['vip'],
- 'healthmonitor': network_fakes.QUOTA['healthmonitor'],
- 'l7policy': network_fakes.QUOTA['l7policy'],
- }
- self.network_mock.update_quota.assert_called_once_with(
- identity_fakes.project_id,
- **kwargs
- )
- self.assertIsNone(result)
+ # TODO(huanxuan): Remove this if condition once the fixed
+ # SDK Quota class is the minimum required version.
+ # This is expected to be SDK release 0.9.13
+ if not hasattr(_quota.Quota, 'allow_get'):
+ # Just run this when sdk <= 0.9.10
+ result = self.cmd.take_action(parsed_args)
+ kwargs = {
+ 'subnet': network_fakes.QUOTA['subnet'],
+ 'network': network_fakes.QUOTA['network'],
+ 'floatingip': network_fakes.QUOTA['floatingip'],
+ 'subnetpool': network_fakes.QUOTA['subnetpool'],
+ 'security_group_rule':
+ network_fakes.QUOTA['security_group_rule'],
+ 'security_group': network_fakes.QUOTA['security_group'],
+ 'router': network_fakes.QUOTA['router'],
+ 'rbac_policy': network_fakes.QUOTA['rbac_policy'],
+ 'port': network_fakes.QUOTA['port'],
+ 'vip': network_fakes.QUOTA['vip'],
+ 'healthmonitor': network_fakes.QUOTA['healthmonitor'],
+ 'l7policy': network_fakes.QUOTA['l7policy'],
+ }
+ self.network_mock.update_quota.assert_called_once_with(
+ identity_fakes.project_id,
+ **kwargs
+ )
+ self.assertIsNone(result)
def test_quota_set_with_class(self):
arglist = [
@@ -476,15 +483,20 @@ class TestQuotaShow(TestQuota):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- self.cmd.take_action(parsed_args)
-
- self.quotas_mock.defaults.assert_called_once_with(
- identity_fakes.project_id)
- self.volume_quotas_mock.defaults.assert_called_once_with(
- identity_fakes.project_id)
- self.network.get_quota_default.assert_called_once_with(
- identity_fakes.project_id)
- self.assertNotCalled(self.network.get_quota)
+ # TODO(huanxuan): Remove this if condition once the fixed
+ # SDK QuotaDefault class is the minimum required version.
+ # This is expected to be SDK release 0.9.13
+ if not hasattr(_quota.QuotaDefault, 'project'):
+ # Just run this when sdk <= 0.9.10
+ self.cmd.take_action(parsed_args)
+
+ self.quotas_mock.defaults.assert_called_once_with(
+ identity_fakes.project_id)
+ self.volume_quotas_mock.defaults.assert_called_once_with(
+ identity_fakes.project_id)
+ self.network.get_quota_default.assert_called_once_with(
+ identity_fakes.project_id)
+ self.assertNotCalled(self.network.get_quota)
def test_quota_show_with_class(self):
arglist = [