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: accomodate new back-end restriction on retention period. #6388

Merged
merged 2 commits into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions storage/google/cloud/storage/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,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 @@ -1573,13 +1573,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