Skip to content

Commit 3b06f9e

Browse files
authored
tests: harden 'test_bucket_w_default_event_based_hold' (#468)
Reload blob w/ spurious EBH. Closes #435.
1 parent 73ee6e3 commit 3b06f9e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/system/test_system.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from google.api_core import path_template
4343
import google.oauth2
4444
from test_utils.retry import RetryErrors
45+
from test_utils.retry import RetryInstanceState
4546
from test_utils.system import unique_resource_id
4647
from test_utils.vpcsc_config import vpcsc_config
4748

@@ -57,12 +58,17 @@ def _bad_copy(bad_request):
5758
return err_msg.startswith("No file found in request. (POST") and "copyTo" in err_msg
5859

5960

61+
def _no_event_based_hold(blob):
62+
return not blob.event_based_hold
63+
64+
6065
retry_429 = RetryErrors(exceptions.TooManyRequests, max_tries=6)
6166
retry_429_harder = RetryErrors(exceptions.TooManyRequests, max_tries=10)
6267
retry_429_503 = RetryErrors(
6368
[exceptions.TooManyRequests, exceptions.ServiceUnavailable], max_tries=10
6469
)
6570
retry_bad_copy = RetryErrors(exceptions.BadRequest, error_predicate=_bad_copy)
71+
retry_no_event_based_hold = RetryInstanceState(_no_event_based_hold)
6672

6773

6874
def _empty_bucket(client, bucket):
@@ -2482,6 +2488,11 @@ def test_bucket_w_default_event_based_hold(self):
24822488
self.assertFalse(bucket.retention_policy_locked)
24832489

24842490
blob.upload_from_string(payload)
2491+
2492+
# https://github.com/googleapis/python-storage/issues/435
2493+
if blob.event_based_hold:
2494+
retry_no_event_based_hold(blob.reload)()
2495+
24852496
self.assertFalse(blob.event_based_hold)
24862497
self.assertFalse(blob.temporary_hold)
24872498
self.assertIsNone(blob.retention_expiration_time)

0 commit comments

Comments
 (0)