summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/common
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-10-12 11:22:09 +0000
committerGerrit Code Review <review@openstack.org>2022-10-12 11:22:09 +0000
commitccd935655000682102d2f024e6a0219064ac9320 (patch)
treecd5f39dcb4b420299c68a2767d28b3fb97b6163c /openstackclient/tests/unit/common
parent351b2b107431aaad620bf47286ec234d5cf48bf2 (diff)
parent04e68e0d5a49be93f79d6d71821ab8cd0b0ce589 (diff)
downloadpython-openstackclient-ccd935655000682102d2f024e6a0219064ac9320.tar.gz
Merge "quota: Add 'quota show --usage' option"
Diffstat (limited to 'openstackclient/tests/unit/common')
-rw-r--r--openstackclient/tests/unit/common/test_quota.py68
1 files changed, 54 insertions, 14 deletions
diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py
index 663b62ea..53aab5f2 100644
--- a/openstackclient/tests/unit/common/test_quota.py
+++ b/openstackclient/tests/unit/common/test_quota.py
@@ -1094,17 +1094,20 @@ class TestQuotaShow(TestQuota):
self.cmd.take_action(parsed_args)
self.compute_quotas_mock.get.assert_called_once_with(
- self.projects[0].id, detail=False
+ self.projects[0].id,
+ detail=False,
)
self.volume_quotas_mock.get.assert_called_once_with(
- self.projects[0].id, usage=False
+ self.projects[0].id,
+ usage=False,
)
self.network.get_quota.assert_called_once_with(
- self.projects[0].id, details=False
+ self.projects[0].id,
+ details=False,
)
self.assertNotCalled(self.network.get_quota_default)
- def test_quota_show_with_default(self):
+ def test_quota_show__with_default(self):
arglist = [
'--default',
self.projects[0].name,
@@ -1128,30 +1131,67 @@ class TestQuotaShow(TestQuota):
)
self.assertNotCalled(self.network.get_quota)
- def test_quota_show_with_class(self):
+ def test_quota_show__with_class(self):
arglist = [
'--class',
- self.projects[0].name,
+ 'default',
]
verifylist = [
('quota_class', True),
- ('project', self.projects[0].name),
+ ('project', 'default'), # project is actually a class here
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
- self.compute_quotas_class_mock.get.assert_called_once_with(
+ self.compute_quotas_class_mock.get.assert_called_once_with('default')
+ self.volume_quotas_class_mock.get.assert_called_once_with('default')
+ # neutron doesn't have the concept of quota classes
+ self.assertNotCalled(self.network.get_quota)
+ self.assertNotCalled(self.network.get_quota_default)
+
+ def test_quota_show__with_usage(self):
+ # update mocks to return detailed quota instead
+ self.compute_quota = \
+ compute_fakes.FakeQuota.create_one_comp_detailed_quota()
+ self.compute_quotas_mock.get.return_value = self.compute_quota
+ self.volume_quota = \
+ volume_fakes.FakeQuota.create_one_detailed_quota()
+ self.volume_quotas_mock.get.return_value = self.volume_quota
+ self.network.get_quota.return_value = \
+ network_fakes.FakeQuota.create_one_net_detailed_quota()
+
+ arglist = [
+ '--usage',
self.projects[0].name,
+ ]
+ verifylist = [
+ ('usage', True),
+ ('project', self.projects[0].name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.compute_quotas_mock.get.assert_called_once_with(
+ self.projects[0].id,
+ detail=True,
)
- self.volume_quotas_class_mock.get.assert_called_once_with(
- self.projects[0].name,
+ self.volume_quotas_mock.get.assert_called_once_with(
+ self.projects[0].id,
+ usage=True,
+ )
+ self.network.get_quota.assert_called_once_with(
+ self.projects[0].id,
+ details=True,
)
- self.assertNotCalled(self.network.get_quota)
- self.assertNotCalled(self.network.get_quota_default)
- def test_quota_show_no_project(self):
- parsed_args = self.check_parser(self.cmd, [], [])
+ def test_quota_show__no_project(self):
+ arglist = []
+ verifylist = [
+ ('project', None),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)