@@ -751,7 +751,10 @@ def test__get_download_url_with_media_link(self):
751
751
# Set the media link on the blob
752
752
blob ._properties ["mediaLink" ] = media_link
753
753
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
+
755
758
self .assertEqual (download_url , media_link )
756
759
757
760
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):
763
766
# Set the media link on the blob
764
767
blob ._properties ["mediaLink" ] = media_link
765
768
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
+
767
773
self .assertEqual (
768
774
download_url , "{}?userProject={}" .format (media_link , user_project )
769
775
)
@@ -774,7 +780,9 @@ def test__get_download_url_on_the_fly(self):
774
780
blob = self ._make_one (blob_name , bucket = bucket )
775
781
776
782
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 )
778
786
expected_url = (
779
787
"https://storage.googleapis.com/download/storage/v1/b/"
780
788
"buhkit/o/bzzz-fly.txt?alt=media"
@@ -790,7 +798,9 @@ def test__get_download_url_on_the_fly_with_generation(self):
790
798
blob ._properties ["generation" ] = str (generation )
791
799
792
800
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 )
794
804
expected_url = (
795
805
"https://storage.googleapis.com/download/storage/v1/b/"
796
806
"fictional/o/pretend.txt?alt=media&generation=1493058489532987"
@@ -804,7 +814,9 @@ def test__get_download_url_on_the_fly_with_user_project(self):
804
814
blob = self ._make_one (blob_name , bucket = bucket )
805
815
806
816
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 )
808
820
expected_url = (
809
821
"https://storage.googleapis.com/download/storage/v1/b/"
810
822
"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):
823
835
blob = self ._make_one (blob_name , bucket = bucket , kms_key_name = kms_resource )
824
836
825
837
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 )
827
841
expected_url = (
828
842
"https://storage.googleapis.com/download/storage/v1/b/"
829
843
"buhkit/o/bzzz-fly.txt?alt=media"
@@ -1003,7 +1017,8 @@ def test_download_to_file_with_failure(self):
1003
1017
1004
1018
def test_download_to_file_wo_media_link (self ):
1005
1019
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"
1007
1022
bucket = _Bucket (client )
1008
1023
blob = self ._make_one (blob_name , bucket = bucket )
1009
1024
blob ._do_download = mock .Mock ()
@@ -1319,7 +1334,8 @@ def _do_multipart_success(
1319
1334
transport = self ._mock_transport (http_client .OK , {})
1320
1335
1321
1336
# 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"
1323
1339
data = b"data here hear hier"
1324
1340
stream = io .BytesIO (data )
1325
1341
content_type = u"application/xml"
@@ -1485,7 +1501,8 @@ def _initiate_resumable_helper(
1485
1501
transport = self ._mock_transport (http_client .OK , response_headers )
1486
1502
1487
1503
# 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"
1489
1506
data = b"hello hallo halo hi-low"
1490
1507
stream = io .BytesIO (data )
1491
1508
content_type = u"text/plain"
@@ -1772,7 +1789,8 @@ def _do_resumable_helper(
1772
1789
)
1773
1790
1774
1791
# 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"
1776
1794
stream = io .BytesIO (data )
1777
1795
content_type = u"text/html"
1778
1796
response = blob ._do_resumable_upload (
@@ -2114,7 +2132,8 @@ def _create_resumable_upload_session_helper(self, origin=None, side_effect=None)
2114
2132
# Create some mock arguments and call the method under test.
2115
2133
content_type = u"text/plain"
2116
2134
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"
2118
2137
new_url = blob .create_resumable_upload_session (
2119
2138
content_type = content_type , size = size , origin = origin , client = client
2120
2139
)
0 commit comments