From db5b1603282b4bb7665670c539d224c42dee8a9d Mon Sep 17 00:00:00 2001 From: Pushkar Umaranikar Date: Mon, 13 Feb 2017 22:22:24 +0000 Subject: [PATCH] Placement api: set custom json_error_formatter in root Change decorator for resource based actions in root handler to wsgi_wrapper.PlacementWsgify This is a newly introduced wrapper class around webob.dec.wsgify to set json formatter in case of webob exceptions. Change-Id: I847345f7f15a46930faf8793baf801beba98d368 Closes-Bug: #1635182 --- nova/api/openstack/placement/handlers/root.py | 4 ++-- .../api/openstack/placement/gabbits/microversion.yaml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/placement/handlers/root.py b/nova/api/openstack/placement/handlers/root.py index 6ec8b29d20b1..9b5b1bb948dc 100644 --- a/nova/api/openstack/placement/handlers/root.py +++ b/nova/api/openstack/placement/handlers/root.py @@ -13,13 +13,13 @@ from oslo_serialization import jsonutils from oslo_utils import encodeutils -import webob from nova.api.openstack.placement import microversion +from nova.api.openstack.placement import wsgi_wrapper -@webob.dec.wsgify +@wsgi_wrapper.PlacementWsgify def home(req): min_version = microversion.min_version_string() max_version = microversion.max_version_string() diff --git a/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml b/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml index d6002dd1fceb..72b12e298ece 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml @@ -36,6 +36,8 @@ tests: $.errors.[0].min_version: /^\d+\.\d+$/ response_strings: - "Unacceptable version header: 0.5" + response_json_paths: + $.errors[0].title: Not Acceptable - name: latest microversion is 1.4 GET: / @@ -63,6 +65,8 @@ tests: status: 400 response_strings: - "invalid version string: pony.horse" + response_json_paths: + $.errors[0].title: Bad Request - name: bad format multidot raises 400 GET: / @@ -71,6 +75,8 @@ tests: status: 400 response_strings: - "invalid version string: 1.2.3" + response_json_paths: + $.errors[0].title: Bad Request - name: error in application produces microversion headers desc: we do not want xml