From 9382efb8498b40628753698367d11ea517799a87 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Sun, 17 Oct 2010 11:31:04 -0500 Subject: [PATCH] PUTing and POSTing using image key --- glance/parallax/controllers.py | 4 ++-- tests/unit/test_parallax_api.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/glance/parallax/controllers.py b/glance/parallax/controllers.py index c0a95474fb..3926cb82a7 100644 --- a/glance/parallax/controllers.py +++ b/glance/parallax/controllers.py @@ -96,7 +96,7 @@ def create(self, req): in the 'id' field """ - image_data = json.loads(req.body) + image_data = json.loads(req.body)['image'] # Ensure the image has a status set image_data.setdefault('status', 'available') @@ -116,7 +116,7 @@ def update(self, req, id): :retval Returns the updated image information as a mapping, """ - image_data = json.loads(req.body) + image_data = json.loads(req.body)['image'] context = None updated_image = db.image_update(context, id, image_data) diff --git a/tests/unit/test_parallax_api.py b/tests/unit/test_parallax_api.py index 3964fef263..c9b787e596 100644 --- a/tests/unit/test_parallax_api.py +++ b/tests/unit/test_parallax_api.py @@ -105,7 +105,7 @@ def test_create_image(self): req = webob.Request.blank('/images') req.method = 'POST' - req.body = json.dumps(fixture) + req.body = json.dumps(dict(image=fixture)) res = req.get_response(controllers.API()) @@ -134,7 +134,7 @@ def test_create_image_with_bad_status(self): req = webob.Request.blank('/images') req.method = 'POST' - req.body = json.dumps(fixture) + req.body = json.dumps(dict(image=fixture)) # TODO(jaypipes): Port Nova's Fault infrastructure # over to Glance to support exception catching into @@ -150,7 +150,7 @@ def test_update_image(self): req = webob.Request.blank('/images/2') req.method = 'PUT' - req.body = json.dumps(fixture) + req.body = json.dumps(dict(image=fixture)) res = req.get_response(controllers.API()) @@ -174,7 +174,7 @@ def test_update_image_not_existing(self): req = webob.Request.blank('/images/3') req.method = 'PUT' - req.body = json.dumps(fixture) + req.body = json.dumps(dict(image=fixture)) # TODO(jaypipes): Port Nova's Fault infrastructure # over to Glance to support exception catching into