@@ -176,6 +176,10 @@ def test_build_api_url_w_upload(self):
176176 ])
177177 self .assertEqual (conn .build_api_url ('/foo' , upload = True ), URI )
178178
179+ def _user_agent (self ):
180+ import gcloud
181+ return "gcloud-python/{0}" .format (gcloud .__version__ )
182+
179183 def test_make_request_no_data_no_content_type_no_headers (self ):
180184 PROJECT = 'project'
181185 conn = self ._makeOne (PROJECT )
@@ -194,7 +198,7 @@ def test_make_request_no_data_no_content_type_no_headers(self):
194198 expected_headers = {
195199 'Accept-Encoding' : 'gzip' ,
196200 'Content-Length' : 0 ,
197- 'User-Agent' : conn . USER_AGENT ,
201+ 'User-Agent' : self . _user_agent () ,
198202 }
199203 self .assertEqual (http ._called_with ['headers' ], expected_headers )
200204
@@ -214,7 +218,7 @@ def test_make_request_w_data_no_extra_headers(self):
214218 'Accept-Encoding' : 'gzip' ,
215219 'Content-Length' : 0 ,
216220 'Content-Type' : 'application/json' ,
217- 'User-Agent' : conn . USER_AGENT ,
221+ 'User-Agent' : self . _user_agent () ,
218222 }
219223 self .assertEqual (http ._called_with ['headers' ], expected_headers )
220224
@@ -234,7 +238,7 @@ def test_make_request_w_extra_headers(self):
234238 'Accept-Encoding' : 'gzip' ,
235239 'Content-Length' : 0 ,
236240 'X-Foo' : 'foo' ,
237- 'User-Agent' : conn . USER_AGENT ,
241+ 'User-Agent' : self . _user_agent () ,
238242 }
239243 self .assertEqual (http ._called_with ['headers' ], expected_headers )
240244
@@ -258,7 +262,7 @@ def test_api_request_defaults(self):
258262 expected_headers = {
259263 'Accept-Encoding' : 'gzip' ,
260264 'Content-Length' : 0 ,
261- 'User-Agent' : conn . USER_AGENT ,
265+ 'User-Agent' : self . _user_agent () ,
262266 }
263267 self .assertEqual (http ._called_with ['headers' ], expected_headers )
264268
@@ -305,7 +309,7 @@ def test_api_request_w_query_params(self):
305309 expected_headers = {
306310 'Accept-Encoding' : 'gzip' ,
307311 'Content-Length' : 0 ,
308- 'User-Agent' : conn . USER_AGENT ,
312+ 'User-Agent' : self . _user_agent () ,
309313 }
310314 self .assertEqual (http ._called_with ['headers' ], expected_headers )
311315
@@ -333,7 +337,7 @@ def test_api_request_w_data(self):
333337 'Accept-Encoding' : 'gzip' ,
334338 'Content-Length' : len (DATAJ ),
335339 'Content-Type' : 'application/json' ,
336- 'User-Agent' : conn . USER_AGENT ,
340+ 'User-Agent' : self . _user_agent () ,
337341 }
338342 self .assertEqual (http ._called_with ['headers' ], expected_headers )
339343
0 commit comments