1717from openstackclient .common import quota
1818from openstackclient .tests .compute .v2 import fakes as compute_fakes
1919from openstackclient .tests import fakes
20+ from openstackclient .tests .identity .v2_0 import fakes as identity_fakes
2021
2122
2223class FakeQuotaResource (fakes .FakeResource ):
@@ -45,6 +46,8 @@ def setUp(self):
4546 self .app .client_manager .volume = volume_mock
4647 self .volume_quotas_mock = volume_mock .quotas
4748 self .volume_quotas_mock .reset_mock ()
49+ self .projects_mock = self .app .client_manager .identity .projects
50+ self .projects_mock .reset_mock ()
4851
4952
5053class TestQuotaSet (TestQuota ):
@@ -76,6 +79,12 @@ def setUp(self):
7679 loaded = True ,
7780 )
7881
82+ self .projects_mock .get .return_value = fakes .FakeResource (
83+ None ,
84+ copy .deepcopy (identity_fakes .PROJECT ),
85+ loaded = True ,
86+ )
87+
7988 self .cmd = quota .SetQuota (self .app , None )
8089
8190 def test_quota_set (self ):
@@ -84,14 +93,14 @@ def test_quota_set(self):
8493 '--fixed-ips' , str (compute_fakes .fix_ip_num ),
8594 '--injected-files' , str (compute_fakes .injected_file_num ),
8695 '--key-pairs' , str (compute_fakes .key_pair_num ),
87- compute_fakes .project_name ,
96+ identity_fakes .project_name ,
8897 ]
8998 verifylist = [
9099 ('floating_ips' , compute_fakes .floating_ip_num ),
91100 ('fixed_ips' , compute_fakes .fix_ip_num ),
92101 ('injected_files' , compute_fakes .injected_file_num ),
93102 ('key_pairs' , compute_fakes .key_pair_num ),
94- ('project' , compute_fakes .project_name ),
103+ ('project' , identity_fakes .project_name ),
95104 ]
96105
97106 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
@@ -105,14 +114,17 @@ def test_quota_set(self):
105114 'key_pairs' : compute_fakes .key_pair_num ,
106115 }
107116
108- self .quotas_mock .update .assert_called_with ('project_test' , ** kwargs )
117+ self .quotas_mock .update .assert_called_with (
118+ identity_fakes .project_id ,
119+ ** kwargs
120+ )
109121
110122 def test_quota_set_volume (self ):
111123 arglist = [
112124 '--gigabytes' , str (compute_fakes .floating_ip_num ),
113125 '--snapshots' , str (compute_fakes .fix_ip_num ),
114126 '--volumes' , str (compute_fakes .injected_file_num ),
115- compute_fakes .project_name ,
127+ identity_fakes .project_name ,
116128 ]
117129 verifylist = [
118130 ('gigabytes' , compute_fakes .floating_ip_num ),
@@ -130,5 +142,7 @@ def test_quota_set_volume(self):
130142 'volumes' : compute_fakes .injected_file_num ,
131143 }
132144
133- self .volume_quotas_mock .update .assert_called_with ('project_test' ,
134- ** kwargs )
145+ self .volume_quotas_mock .update .assert_called_with (
146+ identity_fakes .project_id ,
147+ ** kwargs
148+ )
0 commit comments