Correct bug in microversion headers in placement

Found a small bug in the handling of a 406 error by the placement API's
microversion handling code that only appeared when more than one
microversion was used.

Change-Id: I8562e9ce962352033e43a3b993f8b8ba6f211fd4
This commit is contained in:
Jay Pipes 2016-10-10 23:08:30 -04:00
parent 16f4bad6d3
commit 98d629a1a0
2 changed files with 11 additions and 1 deletions

View File

@ -109,7 +109,7 @@ def json_error_formatter(body, status, title, environ):
microversion = nova.api.openstack.placement.microversion
if status_code == 406 and microversion.MICROVERSION_ENVIRON not in environ:
error_dict['max_version'] = microversion.max_version_string()
error_dict['min_version'] = microversion.max_version_string()
error_dict['min_version'] = microversion.min_version_string()
return {'errors': [error_dict]}

View File

@ -13,6 +13,7 @@
"""Unit tests for the utility functions used by the placement API."""
import fixtures
from oslo_middleware import request_id
import webob
@ -143,6 +144,15 @@ class TestJSONErrorFormatter(test.NoDBTestCase):
def setUp(self):
super(TestJSONErrorFormatter, self).setUp()
self.environ = {}
# TODO(jaypipes): Remove this when we get more than a single version
# in the placement API. The fact that we only had a single version was
# masking a bug in the utils code.
_versions = [
'1.0',
'1.1',
]
mod_str = 'nova.api.openstack.placement.microversion.VERSIONS'
self.useFixture(fixtures.MonkeyPatch(mod_str, _versions))
def test_status_to_int_code(self):
body = ''