File tree
Expand file treeCollapse file tree2 files changed
+17
-4
lines changed Expand file treeCollapse file tree2 files changed
+17
-4
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -2361,7 +2361,13 @@ def lifecycle_rules(self):
|
2361 | 2361 | elif action_type == "SetStorageClass":
|
2362 | 2362 | yield LifecycleRuleSetStorageClass.from_api_repr(rule)
|
2363 | 2363 | else:
|
2364 |
| -raise ValueError("Unknown lifecycle rule: {}".format(rule)) |
| 2364 | +warnings.warn( |
| 2365 | +"Unknown lifecycle rule type received: {}. Please upgrade to the latest version of google-cloud-storage.".format( |
| 2366 | +rule |
| 2367 | +), |
| 2368 | +UserWarning, |
| 2369 | +stacklevel=1, |
| 2370 | +) |
2365 | 2371 |
|
2366 | 2372 | @lifecycle_rules.setter
|
2367 | 2373 | def lifecycle_rules(self, rules):
|
|
Original file line number | Diff line number | Diff line change |
---|
@@ -1783,15 +1783,22 @@ def test_iam_configuration_policy_w_entry(self):
|
1783 | 1783 | self.assertTrue(config.uniform_bucket_level_access_enabled)
|
1784 | 1784 | self.assertEqual(config.uniform_bucket_level_access_locked_time, now)
|
1785 | 1785 |
|
1786 |
| -def test_lifecycle_rules_getter_unknown_action_type(self): |
| 1786 | +@mock.("warnings.warn") |
| 1787 | +def test_lifecycle_rules_getter_unknown_action_type(self, mock_warn): |
1787 | 1788 | NAME = "name"
|
1788 | 1789 | BOGUS_RULE = {"action": {"type": "Bogus"}, "condition": {"age": 42}}
|
1789 | 1790 | rules = [BOGUS_RULE]
|
1790 | 1791 | properties = {"lifecycle": {"rule": rules}}
|
1791 | 1792 | bucket = self._make_one(name=NAME, properties=properties)
|
1792 | 1793 |
|
1793 |
| -with self.assertRaises(ValueError): |
1794 |
| -list(bucket.lifecycle_rules) |
| 1794 | +list(bucket.lifecycle_rules) |
| 1795 | +mock_warn.assert_called_with( |
| 1796 | +"Unknown lifecycle rule type received: {}. Please upgrade to the latest version of google-cloud-storage.".format( |
| 1797 | +BOGUS_RULE |
| 1798 | +), |
| 1799 | +UserWarning, |
| 1800 | +stacklevel=1, |
| 1801 | +) |
1795 | 1802 |
|
1796 | 1803 | def test_lifecycle_rules_getter(self):
|
1797 | 1804 | from google.cloud.storage.bucket import (
|
|
You can’t perform that action at this time.
0 commit comments