From b4fb646f4dfeaff8334f97ea3a4631098a29af07 Mon Sep 17 00:00:00 2001 From: juanifioren Date: Thu, 12 Feb 2015 16:56:35 -0300 Subject: [PATCH] Using urllib module to create url. --- openid_provider/tests/test_code_flow.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/openid_provider/tests/test_code_flow.py b/openid_provider/tests/test_code_flow.py index 171b43c..f3fff44 100644 --- a/openid_provider/tests/test_code_flow.py +++ b/openid_provider/tests/test_code_flow.py @@ -17,14 +17,20 @@ class CodeFlowTestCase(TestCase): self.client = create_fake_client(response_type='code') def _create_authorize_url(self, response_type, scope=['openid', 'email']): - url = reverse('openid_provider:authorize') - url += '?client_id={0}&response_type={1}&scope={2}' \ - '&redirect_uri={3}&state=abcdefg'.format( - self.client.client_id, - urllib.quote(response_type), - urllib.quote(' '.join(scope)), - urllib.quote(self.client.default_redirect_uri), - ) + """ + Generate an OpenID Authentication Request using the fake client data. + """ + path = reverse('openid_provider:authorize') + + query_str = urllib.urlencode({ + 'client_id': self.client.client_id, + 'response_type': response_type, + 'redirect_uri': self.client.default_redirect_uri, + 'scope': ' '.join(scope), + 'state': 'abcdefg', + }).replace('+', '%20') + + url = path + '?' + query_str return url