@@ -332,8 +332,12 @@ def test_upload_from_file_simple(self):
332332 self .assertEqual (scheme , 'http' )
333333 self .assertEqual (netloc , 'example.com' )
334334 self .assertEqual (path , '/b/name/o' )
335- self .assertEqual (dict (parse_qsl (qs )),
336- {'uploadType' : 'media' , 'name' : BLOB_NAME })
335+ query_params = {
336+ 'uploadType' : 'media' ,
337+ 'name' : BLOB_NAME ,
338+ 'project' : 'PROJECT' ,
339+ }
340+ self .assertEqual (dict (parse_qsl (qs )), query_params )
337341 headers = dict (
338342 [(x .title (), str (y )) for x , y in rq [0 ]['headers' ].items ()])
339343 self .assertEqual (headers ['Content-Length' ], '6' )
@@ -376,8 +380,12 @@ def test_upload_from_file_resumable(self):
376380 self .assertEqual (scheme , 'http' )
377381 self .assertEqual (netloc , 'example.com' )
378382 self .assertEqual (path , '/b/name/o' )
379- self .assertEqual (dict (parse_qsl (qs )),
380- {'uploadType' : 'resumable' , 'name' : BLOB_NAME })
383+ query_params = {
384+ 'uploadType' : 'resumable' ,
385+ 'name' : BLOB_NAME ,
386+ 'project' : 'PROJECT' ,
387+ }
388+ self .assertEqual (dict (parse_qsl (qs )), query_params )
381389 headers = dict (
382390 [(x .title (), str (y )) for x , y in rq [0 ]['headers' ].items ()])
383391 self .assertEqual (headers ['X-Upload-Content-Length' ], '6' )
@@ -431,8 +439,12 @@ def test_upload_from_file_w_slash_in_name(self):
431439 self .assertEqual (scheme , 'http' )
432440 self .assertEqual (netloc , 'example.com' )
433441 self .assertEqual (path , '/b/name/o' )
434- self .assertEqual (dict (parse_qsl (qs )),
435- {'uploadType' : 'media' , 'name' : 'parent/child' })
442+ query_params = {
443+ 'uploadType' : 'media' ,
444+ 'name' : 'parent/child' ,
445+ 'project' : 'PROJECT' ,
446+ }
447+ self .assertEqual (dict (parse_qsl (qs )), query_params )
436448 headers = dict (
437449 [(x .title (), str (y )) for x , y in rq [0 ]['headers' ].items ()])
438450 self .assertEqual (headers ['Content-Length' ], '6' )
@@ -471,8 +483,12 @@ def test_upload_from_filename(self):
471483 self .assertEqual (scheme , 'http' )
472484 self .assertEqual (netloc , 'example.com' )
473485 self .assertEqual (path , '/b/name/o' )
474- self .assertEqual (dict (parse_qsl (qs )),
475- {'uploadType' : 'media' , 'name' : BLOB_NAME })
486+ query_params = {
487+ 'uploadType' : 'media' ,
488+ 'name' : BLOB_NAME ,
489+ 'project' : 'PROJECT' ,
490+ }
491+ self .assertEqual (dict (parse_qsl (qs )), query_params )
476492 headers = dict (
477493 [(x .title (), str (y )) for x , y in rq [0 ]['headers' ].items ()])
478494 self .assertEqual (headers ['Content-Length' ], '6' )
@@ -507,8 +523,12 @@ def test_upload_from_string_w_bytes(self):
507523 self .assertEqual (scheme , 'http' )
508524 self .assertEqual (netloc , 'example.com' )
509525 self .assertEqual (path , '/b/name/o' )
510- self .assertEqual (dict (parse_qsl (qs )),
511- {'uploadType' : 'media' , 'name' : BLOB_NAME })
526+ query_params = {
527+ 'project' : 'PROJECT' ,
528+ 'uploadType' : 'media' ,
529+ 'name' : BLOB_NAME ,
530+ }
531+ self .assertEqual (dict (parse_qsl (qs )), query_params )
512532 headers = dict (
513533 [(x .title (), str (y )) for x , y in rq [0 ]['headers' ].items ()])
514534 self .assertEqual (headers ['Content-Length' ], '6' )
@@ -545,8 +565,12 @@ def test_upload_from_string_w_text(self):
545565 self .assertEqual (scheme , 'http' )
546566 self .assertEqual (netloc , 'example.com' )
547567 self .assertEqual (path , '/b/name/o' )
548- self .assertEqual (dict (parse_qsl (qs )),
549- {'uploadType' : 'media' , 'name' : BLOB_NAME })
568+ query_params = {
569+ 'uploadType' : 'media' ,
570+ 'name' : BLOB_NAME ,
571+ 'project' : 'PROJECT' ,
572+ }
573+ self .assertEqual (dict (parse_qsl (qs )), query_params )
550574 headers = dict (
551575 [(x .title (), str (y )) for x , y in rq [0 ]['headers' ].items ()])
552576 self .assertEqual (headers ['Content-Length' ], str (len (ENCODED )))
@@ -906,6 +930,7 @@ class _Connection(_Responder):
906930 API_BASE_URL = 'http://example.com'
907931 USER_AGENT = 'testing 1.2.3'
908932 credentials = object ()
933+ project = 'PROJECT'
909934
910935 def __init__ (self , * responses ):
911936 super (_Connection , self ).__init__ (* responses )
@@ -915,15 +940,17 @@ def __init__(self, *responses):
915940 def api_request (self , ** kw ):
916941 return self ._respond (** kw )
917942
918- def build_api_url (self , path , query_params = None ,
943+ def build_api_url (self , project , path , query_params = None ,
919944 api_base_url = API_BASE_URL , upload = False ):
920945 from six .moves .urllib .parse import urlencode
921946 from six .moves .urllib .parse import urlsplit
922947 from six .moves .urllib .parse import urlunsplit
923948 # mimic the build_api_url interface, but avoid unused param and
924949 # missed coverage errors
925950 upload = not upload # pragma NO COVER
926- qs = urlencode (query_params or {})
951+ query_params = query_params or {}
952+ query_params ['project' ] = project
953+ qs = urlencode (query_params )
927954 scheme , netloc , _ , _ , _ = urlsplit (api_base_url )
928955 return urlunsplit ((scheme , netloc , path , qs , '' ))
929956
0 commit comments