Tests use keep_blank_values when parse_qs

The tests weren't using keep_blank_values when calling
urlparse.parse_qs, so any empty values were just ignored and
couldn't be tested properly. With this change, tests can verify
query parameters that have no value (for example, ?no_catalog on
the v3 auth request).

bp auth-token-use-client

Change-Id: Iafcb952c81ca7bd2acab4383687c36ec68a838d2
This commit is contained in:
Brant Knudson
2015-01-29 17:41:42 -06:00
parent 019c383cb4
commit 9a9f47b95f

View File

@@ -86,14 +86,23 @@ class TestCase(testtools.TestCase):
The qs parameter should be of the format \'foo=bar&abc=xyz\' The qs parameter should be of the format \'foo=bar&abc=xyz\'
""" """
expected = urlparse.parse_qs(qs) expected = urlparse.parse_qs(qs, keep_blank_values=True)
parts = urlparse.urlparse(self.requests.last_request.url) parts = urlparse.urlparse(self.requests.last_request.url)
querystring = urlparse.parse_qs(parts.query) querystring = urlparse.parse_qs(parts.query, keep_blank_values=True)
self.assertEqual(expected, querystring) self.assertEqual(expected, querystring)
def assertQueryStringContains(self, **kwargs): def assertQueryStringContains(self, **kwargs):
"""Verify the query string contains the expected parameters.
This method is used to verify that the query string for the most recent
request made contains all the parameters provided as ``kwargs``, and
that the value of each parameter contains the value for the kwarg. If
the value for the kwarg is an empty string (''), then all that's
verified is that the parameter is present.
"""
parts = urlparse.urlparse(self.requests.last_request.url) parts = urlparse.urlparse(self.requests.last_request.url)
qs = urlparse.parse_qs(parts.query) qs = urlparse.parse_qs(parts.query, keep_blank_values=True)
for k, v in six.iteritems(kwargs): for k, v in six.iteritems(kwargs):
self.assertIn(k, qs) self.assertIn(k, qs)