@@ -751,7 +751,10 @@ def test__get_download_url_with_media_link(self):
751751 # Set the media link on the blob
752752 blob ._properties ["mediaLink" ] = media_link
753753
754- download_url = blob ._get_download_url ()
754+ client = mock .Mock (_connection = _Connection )
755+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
756+ download_url = blob ._get_download_url (client )
757+
755758 self .assertEqual (download_url , media_link )
756759
757760 def test__get_download_url_with_media_link_w_user_project (self ):
@@ -763,7 +766,10 @@ def test__get_download_url_with_media_link_w_user_project(self):
763766 # Set the media link on the blob
764767 blob ._properties ["mediaLink" ] = media_link
765768
766- download_url = blob ._get_download_url ()
769+ client = mock .Mock (_connection = _Connection )
770+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
771+ download_url = blob ._get_download_url (client )
772+
767773 self .assertEqual (
768774 download_url , "{}?userProject={}" .format (media_link , user_project )
769775 )
@@ -774,7 +780,9 @@ def test__get_download_url_on_the_fly(self):
774780 blob = self ._make_one (blob_name , bucket = bucket )
775781
776782 self .assertIsNone (blob .media_link )
777- download_url = blob ._get_download_url ()
783+ client = mock .Mock (_connection = _Connection )
784+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
785+ download_url = blob ._get_download_url (client )
778786 expected_url = (
779787 "https://storage.googleapis.com/download/storage/v1/b/"
780788 "buhkit/o/bzzz-fly.txt?alt=media"
@@ -790,7 +798,9 @@ def test__get_download_url_on_the_fly_with_generation(self):
790798 blob ._properties ["generation" ] = str (generation )
791799
792800 self .assertIsNone (blob .media_link )
793- download_url = blob ._get_download_url ()
801+ client = mock .Mock (_connection = _Connection )
802+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
803+ download_url = blob ._get_download_url (client )
794804 expected_url = (
795805 "https://storage.googleapis.com/download/storage/v1/b/"
796806 "fictional/o/pretend.txt?alt=media&generation=1493058489532987"
@@ -804,7 +814,9 @@ def test__get_download_url_on_the_fly_with_user_project(self):
804814 blob = self ._make_one (blob_name , bucket = bucket )
805815
806816 self .assertIsNone (blob .media_link )
807- download_url = blob ._get_download_url ()
817+ client = mock .Mock (_connection = _Connection )
818+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
819+ download_url = blob ._get_download_url (client )
808820 expected_url = (
809821 "https://storage.googleapis.com/download/storage/v1/b/"
810822 "fictional/o/pretend.txt?alt=media&userProject={}" .format (user_project )
@@ -823,7 +835,9 @@ def test__get_download_url_on_the_fly_with_kms_key_name(self):
823835 blob = self ._make_one (blob_name , bucket = bucket , kms_key_name = kms_resource )
824836
825837 self .assertIsNone (blob .media_link )
826- download_url = blob ._get_download_url ()
838+ client = mock .Mock (_connection = _Connection )
839+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
840+ download_url = blob ._get_download_url (client )
827841 expected_url = (
828842 "https://storage.googleapis.com/download/storage/v1/b/"
829843 "buhkit/o/bzzz-fly.txt?alt=media"
@@ -1003,7 +1017,8 @@ def test_download_to_file_with_failure(self):
10031017
10041018 def test_download_to_file_wo_media_link (self ):
10051019 blob_name = "blob-name"
1006- client = mock .Mock (spec = [u"_http" ])
1020+ client = mock .Mock (_connection = _Connection , spec = [u"_http" ])
1021+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
10071022 bucket = _Bucket (client )
10081023 blob = self ._make_one (blob_name , bucket = bucket )
10091024 blob ._do_download = mock .Mock ()
@@ -1319,7 +1334,8 @@ def _do_multipart_success(
13191334 transport = self ._mock_transport (http_client .OK , {})
13201335
13211336 # Create some mock arguments.
1322- client = mock .Mock (_http = transport , spec = ["_http" ])
1337+ client = mock .Mock (_http = transport , _connection = _Connection , spec = ["_http" ])
1338+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
13231339 data = b"data here hear hier"
13241340 stream = io .BytesIO (data )
13251341 content_type = u"application/xml"
@@ -1485,7 +1501,8 @@ def _initiate_resumable_helper(
14851501 transport = self ._mock_transport (http_client .OK , response_headers )
14861502
14871503 # Create some mock arguments and call the method under test.
1488- client = mock .Mock (_http = transport , spec = [u"_http" ])
1504+ client = mock .Mock (_http = transport , _connection = _Connection , spec = [u"_http" ])
1505+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
14891506 data = b"hello hallo halo hi-low"
14901507 stream = io .BytesIO (data )
14911508 content_type = u"text/plain"
@@ -1772,7 +1789,8 @@ def _do_resumable_helper(
17721789 )
17731790
17741791 # Create some mock arguments and call the method under test.
1775- client = mock .Mock (_http = transport , spec = ["_http" ])
1792+ client = mock .Mock (_http = transport , _connection = _Connection , spec = ["_http" ])
1793+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
17761794 stream = io .BytesIO (data )
17771795 content_type = u"text/html"
17781796 response = blob ._do_resumable_upload (
@@ -2114,7 +2132,8 @@ def _create_resumable_upload_session_helper(self, origin=None, side_effect=None)
21142132 # Create some mock arguments and call the method under test.
21152133 content_type = u"text/plain"
21162134 size = 10000
2117- client = mock .Mock (_http = transport , spec = [u"_http" ])
2135+ client = mock .Mock (_http = transport , _connection = _Connection , spec = [u"_http" ])
2136+ client ._connection .API_BASE_URL = "https://storage.googleapis.com"
21182137 new_url = blob .create_resumable_upload_session (
21192138 content_type = content_type , size = size , origin = origin , client = client
21202139 )
0 commit comments