Merge "Add strict Boolean checking for quota show"

This commit is contained in:
Jenkins 2016-06-30 04:05:12 +00:00 committed by Gerrit Code Review
commit cf871a77fc
2 changed files with 12 additions and 1 deletions

View File

@ -159,7 +159,7 @@ class QuotaSetsController(wsgi.Controller):
target_project_id = id
if not hasattr(params, '__call__') and 'usage' in params:
usage = strutils.bool_from_string(params['usage'])
usage = utils.get_bool_param('usage', params)
else:
usage = False

View File

@ -188,6 +188,17 @@ class QuotaSetsControllerTest(QuotaSetsControllerTestBase):
self.controller._get_quotas.assert_called_with(
self.req.environ['cinder.context'], fake.PROJECT_ID, False)
def test_show_with_invalid_usage_param(self):
self.req.params = {'usage': 'InvalidBool'}
self.assertRaises(exception.InvalidParameterValue,
self.controller.show,
self.req, fake.PROJECT2_ID)
def test_show_with_valid_usage_param(self):
self.req.params = {'usage': 'false'}
result = self.controller.show(self.req, fake.PROJECT_ID)
self.assertDictMatch(make_body(), result)
def test_update(self):
body = make_body(gigabytes=2000, snapshots=15,
volumes=5, backups=5, tenant_id=None)