summaryrefslogtreecommitdiff
path: root/openstackclient/tests/common/test_quota.py
diff options
context:
space:
mode:
authorTerryHowe <terrylhowe@gmail.com>2015-08-11 14:40:53 -0600
committerTerryHowe <terrylhowe@gmail.com>2015-08-11 14:40:53 -0600
commitb1ce0356f2e6fc4e36471394d0f871a3d1e6d2e5 (patch)
tree1dbd87f1313fc4a3be03527ae7f7b50f28c52ac9 /openstackclient/tests/common/test_quota.py
parent0cc1e5aa2b7ff7fa55e6083a397c07fc1cc744dd (diff)
downloadpython-openstackclient-b1ce0356f2e6fc4e36471394d0f871a3d1e6d2e5.tar.gz
Add tests for volume quota set
Add some tests for volume quota set and get rid of TODO about using the value instead of the key to get the attribute. Change-Id: I57aa57951aeea65965966e63af922cda532d759d
Diffstat (limited to 'openstackclient/tests/common/test_quota.py')
-rw-r--r--openstackclient/tests/common/test_quota.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/openstackclient/tests/common/test_quota.py b/openstackclient/tests/common/test_quota.py
index f0013e48..b6ad1566 100644
--- a/openstackclient/tests/common/test_quota.py
+++ b/openstackclient/tests/common/test_quota.py
@@ -12,6 +12,8 @@
import copy
+import mock
+
from openstackclient.common import quota
from openstackclient.tests.compute.v2 import fakes as compute_fakes
from openstackclient.tests import fakes
@@ -38,6 +40,11 @@ class TestQuota(compute_fakes.TestComputev2):
super(TestQuota, self).setUp()
self.quotas_mock = self.app.client_manager.compute.quotas
self.quotas_mock.reset_mock()
+ volume_mock = mock.Mock()
+ volume_mock.quotas = mock.Mock()
+ self.app.client_manager.volume = volume_mock
+ self.volume_quotas_mock = volume_mock.quotas
+ self.volume_quotas_mock.reset_mock()
class TestQuotaSet(TestQuota):
@@ -57,6 +64,18 @@ class TestQuotaSet(TestQuota):
loaded=True,
)
+ self.volume_quotas_mock.find.return_value = FakeQuotaResource(
+ None,
+ copy.deepcopy(compute_fakes.QUOTA),
+ loaded=True,
+ )
+
+ self.volume_quotas_mock.update.return_value = FakeQuotaResource(
+ None,
+ copy.deepcopy(compute_fakes.QUOTA),
+ loaded=True,
+ )
+
self.cmd = quota.SetQuota(self.app, None)
def test_quota_set(self):
@@ -87,3 +106,29 @@ class TestQuotaSet(TestQuota):
}
self.quotas_mock.update.assert_called_with('project_test', **kwargs)
+
+ def test_quota_set_volume(self):
+ arglist = [
+ '--gigabytes', str(compute_fakes.floating_ip_num),
+ '--snapshots', str(compute_fakes.fix_ip_num),
+ '--volumes', str(compute_fakes.injected_file_num),
+ compute_fakes.project_name,
+ ]
+ verifylist = [
+ ('gigabytes', compute_fakes.floating_ip_num),
+ ('snapshots', compute_fakes.fix_ip_num),
+ ('volumes', compute_fakes.injected_file_num),
+ ]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ kwargs = {
+ 'gigabytes': compute_fakes.floating_ip_num,
+ 'snapshots': compute_fakes.fix_ip_num,
+ 'volumes': compute_fakes.injected_file_num,
+ }
+
+ self.volume_quotas_mock.update.assert_called_with('project_test',
+ **kwargs)