@@ -231,6 +231,8 @@ def test_create_with_networks_max_count_none(self, provision_instances,
231
231
requested_networks = requested_networks ,
232
232
max_count = None )
233
233
234
+ @mock .patch ('nova.objects.Quotas.get_all_by_project_and_user' ,
235
+ new = mock .MagicMock ())
234
236
@mock .patch ('nova.objects.Quotas.count_as_dict' )
235
237
@mock .patch ('nova.objects.Quotas.limit_check' )
236
238
@mock .patch ('nova.objects.Quotas.limit_check_project_and_user' )
@@ -4170,6 +4172,8 @@ def test_check_injected_file_quota_onset_file_content_limit(self):
4170
4172
self ._test_check_injected_file_quota_onset_file_limit_exceeded ,
4171
4173
side_effect )
4172
4174
4175
+ @mock .patch ('nova.objects.Quotas.get_all_by_project_and_user' ,
4176
+ new = mock .MagicMock ())
4173
4177
@mock .patch ('nova.objects.Quotas.count_as_dict' )
4174
4178
@mock .patch ('nova.objects.Quotas.limit_check_project_and_user' )
4175
4179
@mock .patch ('nova.objects.Instance.save' )
@@ -4194,9 +4198,11 @@ def test_restore_by_admin(self, update_qfd, action_start, instance_save,
4194
4198
self .assertEqual (instance .task_state , task_states .RESTORING )
4195
4199
# mock.ANY might be 'instances', 'cores', or 'ram' depending on how the
4196
4200
# deltas dict is iterated in check_deltas
4201
+ # user_id is expected to be None because no per-user quotas have been
4202
+ # defined
4197
4203
quota_count .assert_called_once_with (admin_context , mock .ANY ,
4198
4204
instance .project_id ,
4199
- user_id = instance . user_id )
4205
+ user_id = None )
4200
4206
quota_check .assert_called_once_with (
4201
4207
admin_context ,
4202
4208
user_values = {'instances' : 2 ,
@@ -4205,9 +4211,11 @@ def test_restore_by_admin(self, update_qfd, action_start, instance_save,
4205
4211
project_values = {'instances' : 2 ,
4206
4212
'cores' : 1 + instance .flavor .vcpus ,
4207
4213
'ram' : 512 + instance .flavor .memory_mb },
4208
- project_id = instance .project_id , user_id = instance . user_id )
4214
+ project_id = instance .project_id )
4209
4215
update_qfd .assert_called_once_with (admin_context , instance , False )
4210
4216
4217
+ @mock .patch ('nova.objects.Quotas.get_all_by_project_and_user' ,
4218
+ new = mock .MagicMock ())
4211
4219
@mock .patch ('nova.objects.Quotas.count_as_dict' )
4212
4220
@mock .patch ('nova.objects.Quotas.limit_check_project_and_user' )
4213
4221
@mock .patch ('nova.objects.Instance.save' )
@@ -4231,9 +4239,11 @@ def test_restore_by_instance_owner(self, update_qfd, action_start,
4231
4239
self .assertEqual (instance .task_state , task_states .RESTORING )
4232
4240
# mock.ANY might be 'instances', 'cores', or 'ram' depending on how the
4233
4241
# deltas dict is iterated in check_deltas
4242
+ # user_id is expected to be None because no per-user quotas have been
4243
+ # defined
4234
4244
quota_count .assert_called_once_with (self .context , mock .ANY ,
4235
4245
instance .project_id ,
4236
- user_id = instance . user_id )
4246
+ user_id = None )
4237
4247
quota_check .assert_called_once_with (
4238
4248
self .context ,
4239
4249
user_values = {'instances' : 2 ,
@@ -4242,7 +4252,7 @@ def test_restore_by_instance_owner(self, update_qfd, action_start,
4242
4252
project_values = {'instances' : 2 ,
4243
4253
'cores' : 1 + instance .flavor .vcpus ,
4244
4254
'ram' : 512 + instance .flavor .memory_mb },
4245
- project_id = instance .project_id , user_id = instance . user_id )
4255
+ project_id = instance .project_id )
4246
4256
update_qfd .assert_called_once_with (self .context , instance , False )
4247
4257
4248
4258
@mock .patch .object (objects .InstanceAction , 'action_start' )
0 commit comments