Skip to content

Commit

Permalink
add additional system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsg committed Apr 14, 2022
1 parent e453c06 commit 946b583
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions google/cloud/storage/bucket.py
Expand Up @@ -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`.
"""
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions tests/system/test_bucket.py
Expand Up @@ -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) == []


Expand Down

0 comments on commit 946b583

Please sign in to comment.