Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: fix Client download_blob_to_file fails #8440

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion storage/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,21 @@ def test_copy_existing_file(self):
copied_contents = new_blob.download_as_string()
self.assertEqual(base_contents, copied_contents)

def test_download_blob_w_uri(self):
blob = self.bucket.blob("MyBuffer")
file_contents = b"Hello World"
blob.upload_from_string(file_contents)
self.case_blobs_to_delete.append(blob)

temp_filename = tempfile.mktemp()
with open(temp_filename, "wb") as file_obj:
Config.CLIENT.download_blob_to_file('gs://'+self.bucket.name+'/MyBuffer', file_obj)
tseaver marked this conversation as resolved.
Show resolved Hide resolved

with open(temp_filename, "rb") as file_obj:
stored_contents = file_obj.read()

self.assertEqual(file_contents, stored_contents)


class TestUnicode(unittest.TestCase):
@unittest.skipIf(RUNNING_IN_VPCSC, "Test is not VPCSC compatible.")
Expand Down Expand Up @@ -585,7 +600,7 @@ def setUpClass(cls):
_empty_bucket(cls.bucket)

logo_path = cls.FILES["logo"]["path"]
blob = storage.Blob(cls.FILENAMES[0], bucket=cls.bucket)
blob = storage.Blob(cls.FILENAMESFILENAMES[0], bucket=cls.bucket)
tseaver marked this conversation as resolved.
Show resolved Hide resolved
blob.upload_from_filename(logo_path)
cls.suite_blobs_to_delete = [blob]

Expand Down