Skip to content
Permalink
Browse files
fix(storage): fix blob metadata to None regression (#60)
  • Loading branch information
IlyaFaer committed Feb 13, 2020
1 parent 8712da8 commit a834d1b54aa96152ced4d841c4e0c241acd2d8d8
Showing with 13 additions and 2 deletions.
  1. +3 −2 google/cloud/storage/blob.py
  2. +10 −0 tests/unit/test_blob.py
@@ -1986,9 +1986,10 @@ def metadata(self, value):
See https://cloud.google.com/storage/docs/json_api/v1/objects
:type value: dict
:param value: (Optional) The blob metadata to set.
:param value: The blob metadata to set.
"""
value = {k: str(v) for k, v in value.items()}
if value is not None:
value = {k: str(v) for k, v in value.items()}
self._patch_property("metadata", value)

@property
@@ -1215,6 +1215,16 @@ def test__get_writable_metadata_unwritable_field(self):
expected = {"name": name}
self.assertEqual(object_metadata, expected)

def test__set_metadata_to_none(self):
name = u"blob-name"
blob = self._make_one(name, bucket=None)
blob.storage_class = "NEARLINE"
blob.cache_control = "max-age=3600"

with mock.patch("google.cloud.storage.blob.Blob._patch_property") as patch_prop:
blob.metadata = None
patch_prop.assert_called_once_with("metadata", None)

def test__get_upload_arguments(self):
name = u"blob-name"
key = b"[pXw@,p@@AfBfrR3x-2b2SCHR,.?YwRO"

0 comments on commit a834d1b

Please sign in to comment.