Skip to content

Commit

Permalink
fix: update 'custom_time' setter to record change (#323)
Browse files Browse the repository at this point in the history
Closes #322.
  • Loading branch information
haim0n authored Nov 24, 2020
1 parent 547740c commit 5174154
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -3613,7 +3613,7 @@ def custom_time(self, value):
if value is not None:
value = _datetime_to_rfc3339(value)

self._properties["customTime"] = value
self._patch_property("customTime", value)


def _get_encryption_headers(key, source=False):
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -3987,6 +3987,7 @@ def test_update_storage_class_w_generation_match(self):
if_generation_match=GENERATION_NUMBER,
if_source_generation_match=SOURCE_GENERATION_NUMBER,
)

self.assertEqual(blob.storage_class, "NEARLINE")

kw = connection._requested
Expand Down Expand Up @@ -4236,6 +4237,7 @@ def test_metadata_setter(self):
self.assertIsNone(blob.metadata)
blob.metadata = METADATA
self.assertEqual(blob.metadata, METADATA)
self.assertIn("metadata", blob._changes)

def test_metadata_setter_w_nan(self):
BLOB_NAME = "blob-name"
Expand All @@ -4246,6 +4248,7 @@ def test_metadata_setter_w_nan(self):
blob.metadata = METADATA
value = blob.metadata["foo"]
self.assertIsInstance(value, str)
self.assertIn("metadata", blob._changes)

def test_metageneration(self):
BUCKET = object()
Expand Down Expand Up @@ -4444,6 +4447,7 @@ def test_custom_time_setter(self):
self.assertIsNone(blob.custom_time)
blob.custom_time = TIMESTAMP
self.assertEqual(blob.custom_time, TIMESTAMP)
self.assertIn("customTime", blob._changes)

def test_custom_time_setter_none_value(self):
from google.cloud._helpers import _RFC3339_MICROS
Expand Down

0 comments on commit 5174154

Please sign in to comment.