1212
1313import copy
1414
15+ import mock
16+
1517from openstackclient .common import quota
1618from openstackclient .tests .compute .v2 import fakes as compute_fakes
1719from openstackclient .tests import fakes
@@ -38,6 +40,11 @@ def setUp(self):
3840 super (TestQuota , self ).setUp ()
3941 self .quotas_mock = self .app .client_manager .compute .quotas
4042 self .quotas_mock .reset_mock ()
43+ volume_mock = mock .Mock ()
44+ volume_mock .quotas = mock .Mock ()
45+ self .app .client_manager .volume = volume_mock
46+ self .volume_quotas_mock = volume_mock .quotas
47+ self .volume_quotas_mock .reset_mock ()
4148
4249
4350class TestQuotaSet (TestQuota ):
@@ -57,6 +64,18 @@ def setUp(self):
5764 loaded = True ,
5865 )
5966
67+ self .volume_quotas_mock .find .return_value = FakeQuotaResource (
68+ None ,
69+ copy .deepcopy (compute_fakes .QUOTA ),
70+ loaded = True ,
71+ )
72+
73+ self .volume_quotas_mock .update .return_value = FakeQuotaResource (
74+ None ,
75+ copy .deepcopy (compute_fakes .QUOTA ),
76+ loaded = True ,
77+ )
78+
6079 self .cmd = quota .SetQuota (self .app , None )
6180
6281 def test_quota_set (self ):
@@ -87,3 +106,29 @@ def test_quota_set(self):
87106 }
88107
89108 self .quotas_mock .update .assert_called_with ('project_test' , ** kwargs )
109+
110+ def test_quota_set_volume (self ):
111+ arglist = [
112+ '--gigabytes' , str (compute_fakes .floating_ip_num ),
113+ '--snapshots' , str (compute_fakes .fix_ip_num ),
114+ '--volumes' , str (compute_fakes .injected_file_num ),
115+ compute_fakes .project_name ,
116+ ]
117+ verifylist = [
118+ ('gigabytes' , compute_fakes .floating_ip_num ),
119+ ('snapshots' , compute_fakes .fix_ip_num ),
120+ ('volumes' , compute_fakes .injected_file_num ),
121+ ]
122+
123+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
124+
125+ self .cmd .take_action (parsed_args )
126+
127+ kwargs = {
128+ 'gigabytes' : compute_fakes .floating_ip_num ,
129+ 'snapshots' : compute_fakes .fix_ip_num ,
130+ 'volumes' : compute_fakes .injected_file_num ,
131+ }
132+
133+ self .volume_quotas_mock .update .assert_called_with ('project_test' ,
134+ ** kwargs )
0 commit comments