Skip to content

Commit e91916f

Browse files
committed
test coverage
1 parent aec585b commit e91916f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/unit/test_blob.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from google.cloud.storage.retry import DEFAULT_RETRY
3030
from google.cloud.storage.retry import DEFAULT_RETRY_IF_ETAG_IN_JSON
3131
from google.cloud.storage.retry import DEFAULT_RETRY_IF_GENERATION_SPECIFIED
32-
from google.cloud.storage.retry import DEFAULT_RETRY_IF_METAGENERATION_SPECIFIED
3332

3433

3534
def _make_credentials():
@@ -2853,8 +2852,8 @@ def _do_upload_helper(
28532852
**timeout_kwarg
28542853
)
28552854

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
28582857

28592858
self.assertIs(created_json, mock.sentinel.json)
28602859
response.json.assert_called_once_with()
@@ -2925,11 +2924,11 @@ def test__do_upload_with_num_retries(self):
29252924

29262925
def test__do_upload_with_conditional_retry_success(self):
29272926
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
29292928
)
29302929

29312930
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)
29332932

29342933
def _upload_from_file_helper(self, side_effect=None, **kwargs):
29352934
from google.cloud._helpers import UTC
@@ -3286,9 +3285,6 @@ def _create_resumable_upload_session_helper(
32863285
expected_timeout = timeout
32873286
timeout_kwarg = {"timeout": timeout}
32883287

3289-
if retry is DEFAULT_RETRY_IF_GENERATION_SPECIFIED:
3290-
retry = DEFAULT_RETRY if if_generation_match else None
3291-
32923288
new_url = blob.create_resumable_upload_session(
32933289
content_type=content_type,
32943290
size=size,
@@ -3350,6 +3346,16 @@ def test_create_resumable_upload_session_with_custom_timeout(self):
33503346
def test_create_resumable_upload_session_with_origin(self):
33513347
self._create_resumable_upload_session_helper(origin="http://google.com")
33523348

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+
33533359
def test_create_resumable_upload_session_with_conditional_retry_success(self):
33543360
self._create_resumable_upload_session_helper(
33553361
retry=DEFAULT_RETRY_IF_GENERATION_SPECIFIED, if_generation_match=123456

0 commit comments

Comments
 (0)