From ec58a6a533782ca9458e13e7f8edbeffb60cedb2 Mon Sep 17 00:00:00 2001 From: Andrew Gorcester Date: Thu, 14 Apr 2022 10:52:10 -0700 Subject: [PATCH] experiment to add additional system tests --- google/cloud/storage/bucket.py | 5 +++++ tests/system/test_bucket.py | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/google/cloud/storage/bucket.py b/google/cloud/storage/bucket.py index 31c4117b5..be99ad141 100644 --- a/google/cloud/storage/bucket.py +++ b/google/cloud/storage/bucket.py @@ -377,6 +377,8 @@ def from_api_repr(cls, resource): class LifecycleRuleAbortIncompleteMultipartUpload(dict): """Map a rule aborting incomplete multipart uploads of matching items. + The "age" lifecycle condition is the only supported condition for this rule. + :type kw: dict :params kw: arguments passed to :class:`LifecycleRuleConditions`. """ @@ -2344,6 +2346,9 @@ def add_lifecycle_set_storage_class_rule(self, storage_class, **kw): def add_lifecycle_abort_incomplete_multipart_upload_rule(self, **kw): """Add a "abort incomplete multipart upload" rule to lifestyle rules. + Note that the "age" lifecycle condition is the only supported condition + for this rule. + See https://cloud.google.com/storage/docs/lifecycle and https://cloud.google.com/storage/docs/json_api/v1/buckets diff --git a/tests/system/test_bucket.py b/tests/system/test_bucket.py index 7905c8956..4fdcfe526 100644 --- a/tests/system/test_bucket.py +++ b/tests/system/test_bucket.py @@ -94,9 +94,21 @@ def test_bucket_lifecycle_rules(storage_client, buckets_to_delete): assert bucket.name == bucket_name assert list(bucket.lifecycle_rules) == expected_rules + # Test modifying lifecycle rules + expected_rules[0]['age'] = 30 + rules = list(bucket.lifecycle_rules) + rules[0]['age'] = 30 + bucket.lifecycle_rules = rules + bucket.patch() + + bucket.reload() + assert list(bucket.lifecycle_rules) == expected_rules + + # Test clearing lifecycle rules bucket.clear_lifecyle_rules() bucket.patch() + bucket.reload() assert list(bucket.lifecycle_rules) == []