|
29 | 29 | from google.cloud.storage.retry import DEFAULT_RETRY |
30 | 30 | from google.cloud.storage.retry import DEFAULT_RETRY_IF_ETAG_IN_JSON |
31 | 31 | from google.cloud.storage.retry import DEFAULT_RETRY_IF_GENERATION_SPECIFIED |
32 | | -from google.cloud.storage.retry import DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED |
33 | 32 |
|
34 | 33 |
|
35 | 34 | def _make_credentials(): |
@@ -2853,8 +2852,8 @@ def _do_upload_helper( |
2853 | 2852 | **timeout_kwarg |
2854 | 2853 | ) |
2855 | 2854 |
|
2856 | | - if retry is DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED: |
2857 | | - retry = DEFAULT_RETRY if if_metageneration_match else None |
| 2855 | + if retry is DEFAULT_RETRY_IF_GENERATION_SPECIFIED: |
| 2856 | + retry = DEFAULT_RETRY if if_generation_match else None |
2858 | 2857 |
|
2859 | 2858 | self.assertIs(created_json, mock.sentinel.json) |
2860 | 2859 | response.json.assert_called_once_with() |
@@ -2925,11 +2924,11 @@ def test__do_upload_with_num_retries(self): |
2925 | 2924 |
|
2926 | 2925 | def test__do_upload_with_conditional_retry_success(self): |
2927 | 2926 | self._do_upload_helper( |
2928 | | - retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED, if_metageneration_match=1 |
| 2927 | + retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED, if_generation_match=123456 |
2929 | 2928 | ) |
2930 | 2929 |
|
2931 | 2930 | def test__do_upload_with_conditional_retry_failure(self): |
2932 | | - self._do_upload_helper(retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED) |
| 2931 | + self._do_upload_helper(retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED) |
2933 | 2932 |
|
2934 | 2933 | def _upload_from_file_helper(self, side_effect=None, **kwargs): |
2935 | 2934 | from google.cloud._helpers import UTC |
@@ -3286,9 +3285,6 @@ def _create_resumable_upload_session_helper( |
3286 | 3285 | expected_timeout = timeout |
3287 | 3286 | timeout_kwarg = {"timeout": timeout} |
3288 | 3287 |
|
3289 | | - if retry is DEFAULT_RETRY_IF_GENERATION_SPECIFIED: |
3290 | | - retry = DEFAULT_RETRY if if_generation_match else None |
3291 | | - |
3292 | 3288 | new_url = blob.create_resumable_upload_session( |
3293 | 3289 | content_type=content_type, |
3294 | 3290 | size=size, |
@@ -3350,6 +3346,16 @@ def test_create_resumable_upload_session_with_custom_timeout(self): |
3350 | 3346 | def test_create_resumable_upload_session_with_origin(self): |
3351 | 3347 | self._create_resumable_upload_session_helper(origin="http://google.com") |
3352 | 3348 |
|
| 3349 | + def test_create_resumable_upload_session_with_generation_match(self): |
| 3350 | + self._create_resumable_upload_session_helper( |
| 3351 | + if_generation_match=123456, if_metageneration_match=2 |
| 3352 | + ) |
| 3353 | + |
| 3354 | + def test_create_resumable_upload_session_with_generation_not_match(self): |
| 3355 | + self._create_resumable_upload_session_helper( |
| 3356 | + if_generation_not_match=0, if_metageneration_not_match=3 |
| 3357 | + ) |
| 3358 | + |
3353 | 3359 | def test_create_resumable_upload_session_with_conditional_retry_success(self): |
3354 | 3360 | self._create_resumable_upload_session_helper( |
3355 | 3361 | retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED, if_generation_match=123456 |
|
0 commit comments