Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cojenco committed Jun 25, 2021
1 parent aec585b commit e91916f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/unit/test_blob.py
Expand Up @@ -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():
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e91916f

Please sign in to comment.