Skip to content

Commit

Permalink
Accomodate new back-end restriction on retention period. (#6388)
Browse files Browse the repository at this point in the history
Closes #6368.
  • Loading branch information
tseaver committed Nov 5, 2018
1 parent c2dd946 commit 062235c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions storage/google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,9 @@ def retention_period(self, value):
"""
policy = self._properties.setdefault('retentionPolicy', {})
if value is not None:
value = str(value)
policy['retentionPeriod'] = value
policy['retentionPeriod'] = str(value)
else:
policy = None
self._patch_property('retentionPolicy', policy)

@property
Expand Down
7 changes: 4 additions & 3 deletions storage/tests/unit/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,13 +1597,14 @@ def test_retention_period_getter(self):
def test_retention_period_setter_w_none(self):
period = 86400 * 100 # 100 days
bucket = self._make_one()
policy = bucket._properties['retentionPolicy'] = {}
policy['retentionPeriod'] = period
bucket._properties['retentionPolicy'] = {
'retentionPeriod': period,
}

bucket.retention_period = None

self.assertIsNone(
bucket._properties['retentionPolicy']['retentionPeriod'])
bucket._properties['retentionPolicy'])

def test_retention_period_setter_w_int(self):
period = 86400 * 100 # 100 days
Expand Down

0 comments on commit 062235c

Please sign in to comment.