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
This commit is contained in:
parent
0a642e2eee
commit
5b00f19109
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue