Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage): add arguments for *GenerationMatch uploading options #111

Merged
merged 7 commits into from
Apr 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add unit tests for _do_multipart_upload()
  • Loading branch information
IlyaFaer committed Apr 21, 2020
commit baaa279dd8bbab186e7e43f06b32363dfb25d619
24 changes: 24 additions & 0 deletions tests/unit/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,18 @@ def _do_multipart_success(
if kms_key_name is not None:
qs_params.append(("kmsKeyName", kms_key_name))

if if_generation_match is not None:
qs_params.append(("ifGenerationMatch", if_generation_match))

if if_generation_not_match is not None:
qs_params.append(("ifGenerationNotMatch", if_generation_not_match))

if if_metageneration_match is not None:
qs_params.append(("ifMetagenerationMatch", if_metageneration_match))

if if_metageneration_not_match is not None:
qs_params.append(("ifMetaGenerationNotMatch", if_metageneration_not_match))

upload_url += "?" + urlencode(qs_params)

payload = (
Expand Down Expand Up @@ -1405,6 +1417,18 @@ def test__do_multipart_upload_with_kms(self, mock_get_boundary):
def test__do_multipart_upload_with_retry(self, mock_get_boundary):
self._do_multipart_success(mock_get_boundary, num_retries=8)

@mock.patch(u"google.resumable_media._upload.get_boundary", return_value=b"==0==")
def test__do_multipart_upload_with_generation_match(self, mock_get_boundary):
self._do_multipart_success(
mock_get_boundary, if_generation_match=4, if_metageneration_match=4
)

@mock.patch(u"google.resumable_media._upload.get_boundary", return_value=b"==0==")
def test__do_multipart_upload_with_generation_not_match(self, mock_get_boundary):
self._do_multipart_success(
mock_get_boundary, if_generation_not_match=4, if_metageneration_not_match=4
)

def test__do_multipart_upload_bad_size(self):
blob = self._make_one(u"blob-name", bucket=None)

Expand Down