diff --git a/tests/unit/test_blob.py b/tests/unit/test_blob.py index 85afc04fd..592265fc2 100644 --- a/tests/unit/test_blob.py +++ b/tests/unit/test_blob.py @@ -29,7 +29,6 @@ from google.cloud.storage.retry import DEFAULT_RETRY from google.cloud.storage.retry import DEFAULT_RETRY_IF_ETAG_IN_JSON from google.cloud.storage.retry import DEFAULT_RETRY_IF_GENERATION_SPECIFIED -from google.cloud.storage.retry import DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED def _make_credentials(): @@ -2853,8 +2852,8 @@ def _do_upload_helper( **timeout_kwarg ) - if retry is DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED: - retry = DEFAULT_RETRY if if_metageneration_match else None + if retry is DEFAULT_RETRY_IF_GENERATION_SPECIFIED: + retry = DEFAULT_RETRY if if_generation_match else None self.assertIs(created_json, mock.sentinel.json) response.json.assert_called_once_with() @@ -2925,11 +2924,11 @@ def test__do_upload_with_num_retries(self): def test__do_upload_with_conditional_retry_success(self): self._do_upload_helper( - retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED, if_metageneration_match=1 + retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED, if_generation_match=123456 ) def test__do_upload_with_conditional_retry_failure(self): - self._do_upload_helper(retry=DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED) + self._do_upload_helper(retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED) def _upload_from_file_helper(self, side_effect=None, **kwargs): from google.cloud._helpers import UTC @@ -3286,9 +3285,6 @@ def _create_resumable_upload_session_helper( expected_timeout = timeout timeout_kwarg = {"timeout": timeout} - if retry is DEFAULT_RETRY_IF_GENERATION_SPECIFIED: - retry = DEFAULT_RETRY if if_generation_match else None - new_url = blob.create_resumable_upload_session( content_type=content_type, size=size, @@ -3350,6 +3346,16 @@ def test_create_resumable_upload_session_with_custom_timeout(self): def test_create_resumable_upload_session_with_origin(self): self._create_resumable_upload_session_helper(origin="http://google.com") + def test_create_resumable_upload_session_with_generation_match(self): + self._create_resumable_upload_session_helper( + if_generation_match=123456, if_metageneration_match=2 + ) + + def test_create_resumable_upload_session_with_generation_not_match(self): + self._create_resumable_upload_session_helper( + if_generation_not_match=0, if_metageneration_not_match=3 + ) + def test_create_resumable_upload_session_with_conditional_retry_success(self): self._create_resumable_upload_session_helper( retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED, if_generation_match=123456