From 00e7019022585bc2be9aeb55eb40b1d04776ec22 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 23 Sep 2022 18:16:53 +0100 Subject: quota: Allow showing project-specific quotas Add '--compute', '--network' and '--volume' options to the 'quota show' command, along with a default '--all' option, allowing us to restrict quotas shown to an individual service. Change-Id: I122b765df01887b8d916ee6567ffb7768fcb4392 Signed-off-by: Stephen Finucane --- openstackclient/tests/unit/common/test_quota.py | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'openstackclient/tests') diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py index 53aab5f2..0900200e 100644 --- a/openstackclient/tests/unit/common/test_quota.py +++ b/openstackclient/tests/unit/common/test_quota.py @@ -1087,6 +1087,7 @@ class TestQuotaShow(TestQuota): self.projects[0].name, ] verifylist = [ + ('service', 'all'), ('project', self.projects[0].name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -1107,6 +1108,67 @@ class TestQuotaShow(TestQuota): ) self.assertNotCalled(self.network.get_quota_default) + def test_quota_show__with_compute(self): + arglist = [ + '--compute', + self.projects[0].name, + ] + verifylist = [ + ('service', 'compute'), + ('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=False, + ) + self.volume_quotas_mock.get.assert_not_called() + self.network.get_quota.assert_not_called() + + def test_quota_show__with_volume(self): + arglist = [ + '--volume', + self.projects[0].name, + ] + verifylist = [ + ('service', 'volume'), + ('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_not_called() + self.volume_quotas_mock.get.assert_called_once_with( + self.projects[0].id, + usage=False, + ) + self.network.get_quota.assert_not_called() + + def test_quota_show__with_network(self): + arglist = [ + '--network', + self.projects[0].name, + ] + verifylist = [ + ('service', 'network'), + ('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_not_called() + self.volume_quotas_mock.get.assert_not_called() + self.network.get_quota.assert_called_once_with( + self.projects[0].id, + details=False, + ) + self.assertNotCalled(self.network.get_quota_default) + def test_quota_show__with_default(self): arglist = [ '--default', -- cgit v1.2.1