diff options
author | Brant Knudson <bknudson@us.ibm.com> | 2015-01-29 17:41:42 -0600 |
---|---|---|
committer | Brant Knudson <bknudson@us.ibm.com> | 2015-01-30 09:57:19 -0600 |
commit | 9a9f47b95f58e9145694e0320709d404a7779a21 (patch) | |
tree | 5c754cf5c4c083223133b12243bc2ff8a29cbae9 | |
parent | 019c383cb44dcdcdf478925627fd58eb4866d230 (diff) | |
download | python-keystoneclient-9a9f47b95f58e9145694e0320709d404a7779a21.tar.gz |
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
-rw-r--r-- | keystoneclient/tests/utils.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/keystoneclient/tests/utils.py b/keystoneclient/tests/utils.py index a6f06c5..290d169 100644 --- a/keystoneclient/tests/utils.py +++ b/keystoneclient/tests/utils.py @@ -86,14 +86,23 @@ class TestCase(testtools.TestCase): 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) - querystring = urlparse.parse_qs(parts.query) + querystring = urlparse.parse_qs(parts.query, keep_blank_values=True) self.assertEqual(expected, querystring) 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) - qs = urlparse.parse_qs(parts.query) + qs = urlparse.parse_qs(parts.query, keep_blank_values=True) for k, v in six.iteritems(kwargs): self.assertIn(k, qs) |