utils.check_string_length(description, 'Type description',
min_length=0, max_length=255)
+ if not utils.is_valid_boolstr(is_public):
+ msg = _("Invalid value '%s' for is_public. Accepted values: "
+ "True or False.") % is_public
+ raise webob.exc.HTTPBadRequest(explanation=msg)
+
try:
volume_types.create(context,
name,
return_volume_types_get_by_name)
body = {"volume_type": {"name": "vol_type_1",
+ "os-volume-type-access:is_public": True,
"extra_specs": {"key1": "value1"}}}
req = fakes.HTTPRequest.blank('/v2/fake/types')
self.assertRaises(webob.exc.HTTPConflict,
self.controller._create, req, body)
+ def test_create_type_with_invalid_is_public(self):
+ body = {"volume_type": {"name": "vol_type_1",
+ "os-volume-type-access:is_public": "fake",
+ "description": "test description",
+ "extra_specs": {"key1": "value1"}}}
+ req = fakes.HTTPRequest.blank('/v2/fake/types')
+ self.assertRaises(webob.exc.HTTPBadRequest,
+ self.controller._create, req, body)
+
def _create_volume_type_bad_body(self, body):
req = fakes.HTTPRequest.blank('/v2/fake/types')
req.method = 'POST'