File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed
Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 3737 from oauth2client .client import AccessTokenRefreshError , \
3838 OAuth2Credentials , AccessTokenCredentialsError
3939 oauth2_supported = True
40- except :
40+ except ImportError :
4141 oauth2_supported = False
4242
43+ try :
44+ from urllib import urlsplit , urlunsplit , quote
45+ except ImportError :
46+ from urllib import quote
47+ from urlparse import urlsplit , urlunsplit
48+
4349import httplib2
4450import json
4551import os
@@ -160,7 +166,11 @@ def __call__(self, req):
160166 'ACCESS_NONCE' : nonce })
161167
162168 elif self .api_key is not None :
163- req .params .update ({'api_key' : api_key })
169+ url_parts = urlsplit (req .url )
170+ new_query = '&' .join (
171+ filter (None , [url_parts .query ,
172+ quote ('api_key={}' .format (self .api_key ))]))
173+ req .url = urlunsplit (url_parts ._replace (query = new_query ))
164174 return req
165175
166176
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ def test_buy_price_with_oauth(self):
2424
2525 def go (self , account ):
2626 this (account .buy_price ()).should .equal (self .expected_price )
27- this (last_request_params ()).should .equal ({'qty' : ['1' ]})
27+ params = last_request_params ()
28+ params .pop ('api_key' , None )
29+ this (params ).should .equal ({'qty' : ['1' ]})
2830
2931 response_body = """
3032 {
@@ -54,7 +56,9 @@ def test_buy_price_with_oauth(self):
5456
5557 def go (self , account ):
5658 this (account .buy_price ('10' )).should .equal (self .expected_price )
57- this (last_request_params ()).should .equal ({'qty' : ['10' ]})
59+ params = last_request_params ()
60+ params .pop ('api_key' , None )
61+ this (params ).should .equal ({'qty' : ['10' ]})
5862
5963 response_body = """
6064 {
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ def test_sell_price_with_oauth(self):
2424
2525 def go (self , account ):
2626 this (account .sell_price ()).should .equal (self .expected_price )
27- this (last_request_params ()).should .equal ({'qty' : ['1' ]})
27+ params = last_request_params ()
28+ params .pop ('api_key' , None )
29+ this (params ).should .equal ({'qty' : ['1' ]})
2830
2931 response_body = """
3032 {
@@ -54,7 +56,9 @@ def test_sell_price_with_oauth(self):
5456
5557 def go (self , account ):
5658 this (account .sell_price (10 )).should .equal (self .expected_price )
57- this (last_request_params ()).should .equal ({'qty' : ['10' ]})
59+ params = last_request_params ()
60+ params .pop ('api_key' , None )
61+ this (params ).should .equal ({'qty' : ['10' ]})
5862
5963 response_body = """
6064 {
You can’t perform that action at this time.
0 commit comments