From 946b5830db120ac9b082201aa3f3b8aaf3aed7ed Mon Sep 17 00:00:00 2001 From: Andrew Gorcester Date: Thu, 14 Apr 2022 11:15:53 -0700 Subject: [PATCH] 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..7d7d7a4a7 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] = LifecycleRuleDelete(age=30) + rules = list(bucket.lifecycle_rules) + rules[0]["condition"] = {"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) == []