try:
project_quotas = QUOTAS.get_project_quotas(
context, target_project.id, usages=True,
- parent_project_id=parent_id)
+ parent_project_id=parent_id, defaults=False)
except exception.NotAuthorized:
raise webob.exc.HTTPForbidden()
result_show_after = self.controller.show(self.req, self.A.id)
self.assertDictMatch(result_show, result_show_after)
+ def test_subproject_delete_not_considering_default_quotas(self):
+ """Test delete subprojects' quotas won't consider default quotas.
+
+ Test plan:
+ - Update the volume quotas of project A
+ - Update the volume quotas of project B
+ - Delete the quotas of project B
+
+ Resources with default quotas aren't expected to be considered when
+ updating the allocated values of the parent project. Thus, the delete
+ operation should succeed.
+ """
+ self.controller._get_project = mock.Mock()
+ self.controller._get_project.side_effect = self._get_project
+ self.req.environ['cinder.context'].project_id = self.A.id
+
+ body = {'quota_set': {'volumes': 5}}
+ result = self.controller.update(self.req, self.A.id, body)
+ self.assertEqual(body['quota_set']['volumes'],
+ result['quota_set']['volumes'])
+
+ body = {'quota_set': {'volumes': 2}}
+ result = self.controller.update(self.req, self.B.id, body)
+ self.assertEqual(body['quota_set']['volumes'],
+ result['quota_set']['volumes'])
+
+ self.controller.delete(self.req, self.B.id)
+
def test_delete_with_allocated_quota_different_from_zero(self):
self.controller._get_project = mock.Mock()
self.controller._get_project.side_effect = self._get_project