]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix error for extra specs update with empty body.
authorAvishay Traeger <avishay@il.ibm.com>
Mon, 21 Jan 2013 08:19:02 +0000 (10:19 +0200)
committerAvishay Traeger <avishay@il.ibm.com>
Mon, 21 Jan 2013 08:22:53 +0000 (10:22 +0200)
Fixes: bug #1090320
Change-Id: Ia2792d477f7670ecb2eb0c9c10dcbf1cf5b2389e

cinder/api/contrib/types_extra_specs.py
cinder/tests/api/contrib/test_types_extra_specs.py

index 40e43d7371c6d04f227890ecf1e011f4ff61891d..5c298d95d4ddfceb49c49da190c13229d492c4fb 100644 (file)
@@ -95,7 +95,8 @@ class VolumeTypeExtraSpecsController(wsgi.Controller):
         context = req.environ['cinder.context']
         authorize(context)
         if not body:
-            raise webob.exc.HTTPUnprocessableEntity()
+            expl = _('Request body empty')
+            raise webob.exc.HTTPBadRequest(explanation=expl)
         self._check_type(context, type_id)
         if not id in body:
             expl = _('Request body and URI mismatch')
index 15baea7d529feb8be9179bf3f6024fd969fba558..49a6da6e44bec553a582fc6c084ca1101a876b67 100644 (file)
@@ -149,6 +149,19 @@ class VolumeTypesExtraSpecsTest(test.TestCase):
         self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
                           req, 1, 'bad', body)
 
+    def _extra_specs_empty_update(self, body):
+        req = fakes.HTTPRequest.blank('/v2/fake/types/1/extra_specs')
+        req.method = 'POST'
+
+        self.assertRaises(webob.exc.HTTPBadRequest,
+                          self.controller.update, req, '1', body)
+
+    def test_update_no_body(self):
+        self._extra_specs_empty_update(body=None)
+
+    def test_update_empty_body(self):
+        self._extra_specs_empty_update(body={})
+
 
 class VolumeTypeExtraSpecsSerializerTest(test.TestCase):
     def test_index_create_serializer(self):
@@ -211,16 +224,3 @@ class VolumeTypeExtraSpecsUnprocessableEntityTestCase(test.TestCase):
     def test_create_malformed_entity(self):
         body = {'extra_specs': 'string'}
         self._unprocessable_extra_specs_create(body=body)
-
-    def _unprocessable_extra_specs_update(self, body):
-        req = fakes.HTTPRequest.blank('/v2/fake/types/1/extra_specs')
-        req.method = 'POST'
-
-        self.assertRaises(webob.exc.HTTPUnprocessableEntity,
-                          self.controller.update, req, '1', body)
-
-    def test_update_no_body(self):
-        self._unprocessable_extra_specs_update(body=None)
-
-    def test_update_empty_body(self):
-        self._unprocessable_extra_specs_update(body={})