From 5b00f19109b5f4d2ae229f7e8d79a4c5f0a66492 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Wed, 25 Apr 2018 16:26:53 +0100 Subject: [PATCH] Make accept-language tests work with webob 1.8.x webob 1.8.x has altered its processing for accept-* headers [1], including being less accomodating of less than well-formed qvalues. If it is unable to parse a header, rather than raising an error of anything like that, a special class of header is created instead. This header still responds on all the same methods as before, but with different results. In the big picture this is a good thing (for correcting processing for content-negotiation) but it is a bit weird for us. This change fixes the immediate short term problem, broken unit tests, by fixing their bad qvalues. The new values will continue to work with old webob. We can hope/assume that most clients will send well-formed qvalues. Longer term we will need to address how the nova Request object is choosing to do best match handling on accept headers to address that webob has deprecated (with a long warning period) methods used by the object. Partial-Bug: #1765748 [1] https://docs.pylonsproject.org/projects/webob/en/stable/whatsnew-1.8.html#backwards-incompatibilities Change-Id: I2034d30cc8d9354be80d39e05b8488cb99c32ecf --- nova/tests/unit/api/openstack/test_wsgi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/tests/unit/api/openstack/test_wsgi.py b/nova/tests/unit/api/openstack/test_wsgi.py index 7727c1c909eb..4b72842ec91f 100644 --- a/nova/tests/unit/api/openstack/test_wsgi.py +++ b/nova/tests/unit/api/openstack/test_wsgi.py @@ -99,7 +99,7 @@ class RequestTest(MicroversionedTest): def test_from_request(self): request = wsgi.Request.blank('/') - accepted = 'bogus;q=1.1, en-gb;q=0.7,en-us,en;q=.5,*;q=.7' + accepted = 'bogus;q=1, en-gb;q=0.7,en-us,en;q=0.5,*;q=0.7' request.headers = {'Accept-Language': accepted} self.assertEqual(request.best_match_language(), 'en_US') @@ -107,7 +107,7 @@ class RequestTest(MicroversionedTest): # asterisk should match first available if there # are not any other available matches request = wsgi.Request.blank('/') - accepted = '*,es;q=.5' + accepted = '*,es;q=0.5' request.headers = {'Accept-Language': accepted} self.assertEqual(request.best_match_language(), 'en_GB') @@ -119,7 +119,7 @@ class RequestTest(MicroversionedTest): def test_secondary(self): request = wsgi.Request.blank('/') - accepted = 'nn,en-gb;q=.5' + accepted = 'nn,en-gb;q=0.5' request.headers = {'Accept-Language': accepted} self.assertEqual(request.best_match_language(), 'en_GB')