Skip to content

Commit

Permalink
Update test function and class names. Enable checksum-algorithm flag …
Browse files Browse the repository at this point in the history
…on copies.
  • Loading branch information
aemous committed Sep 23, 2024
1 parent e9649de commit 9515516
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
8 changes: 4 additions & 4 deletions awscli/customizations/s3/subcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,17 +1380,17 @@ def _raise_if_mv_same_paths(self, src, dest):
f"{self.parameters['src']} - {self.parameters['dest']}"
)

def _raise_if_paths_type_incorrect_for_param(self, param, paths_type, expected_paths_type):
if paths_type not in expected_paths_type:
def _raise_if_paths_type_incorrect_for_param(self, param, paths_type, allowed_paths):
if paths_type not in allowed_paths:
expected_usage_map = {
'locals3': '<LocalPath> <S3Uri>',
's3s3': '<S3Uri> <S3Uri>',
's3local': '<S3Uri> <LocalPath>',
's3': '<S3Uri>'
}
raise ParamValidationError(
"The %s flag is only compatible with the format: %s. You used the format: %s." %
(param, expected_usage_map[expected_paths_type], expected_usage_map[paths_type])
f"Expected {param} parameter to be used with one of following path formats: "
f"{', '.join(allowed_paths)} but received {expected_usage_map[paths_type]}"
)

def _normalize_s3_trailing_slash(self, paths):
Expand Down
1 change: 0 additions & 1 deletion awscli/customizations/s3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ def map_upload_part_params(cls, request_params, cli_params):
"""Map CLI params to UploadPart request params"""
cls._set_sse_c_request_params(request_params, cli_params)
cls._set_request_payer_param(request_params, cli_params)
cls._set_checksum_algorithm_param(request_params, cli_params)

@classmethod
def map_upload_part_copy_params(cls, request_params, cli_params):
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/s3/test_cp_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def test_cp_with_error_and_warning_permissions(self):
self.assertIn('upload failed', stderr)
self.assertIn('warning: File has an invalid timestamp.', stderr)

def test_upload_with_flexible_checksum_crc32(self):
def test_upload_with_checksum_algorithm_crc32(self):
full_path = self.files.create_file('foo.txt', 'contents')
cmdline = (
'%s %s s3://bucket/key.txt --checksum-algorithm CRC32' % (
Expand All @@ -776,7 +776,7 @@ def test_upload_with_flexible_checksum_crc32(self):
})
)

def test_upload_with_flexible_checksum_crc32c(self):
def test_upload_with_checksum_algorithm_crc32c(self):
full_path = self.files.create_file('foo.txt', 'contents')
cmdline = (
'%s %s s3://bucket/key.txt --checksum-algorithm CRC32C' % (
Expand All @@ -792,7 +792,7 @@ def test_upload_with_flexible_checksum_crc32c(self):
})
)

def test_download_with_flexible_checksum_crc32(self):
def test_download_with_checksum_mode_crc32(self):
self.parsed_responses = [
self.head_object_response(),
{
Expand All @@ -809,7 +809,7 @@ def test_download_with_flexible_checksum_crc32(self):
self.assertEqual(self.operations_called[1][0].name, 'GetObject')
self.assertEqual(self.operations_called[1][1]['ChecksumMode'], 'ENABLED')

def test_download_with_flexible_checksum_crc32c(self):
def test_download_with_checksum_mode_crc32c(self):
self.parsed_responses = [
self.head_object_response(),
{
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/s3/test_mv_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_mv_does_not_delete_source_on_failed_put_tagging(self):
]
)

def test_upload_with_flexible_checksum_crc32(self):
def test_upload_with_checksum_algorithm_crc32(self):
full_path = self.files.create_file('foo.txt', 'contents')
cmdline = (
'%s %s s3://bucket/key.txt --checksum-algorithm CRC32' % (
Expand All @@ -260,7 +260,7 @@ def test_upload_with_flexible_checksum_crc32(self):
})
)

def test_download_with_flexible_checksum_crc32(self):
def test_download_with_checksum_mode_crc32(self):
self.parsed_responses = [
self.head_object_response(),
{
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/s3/test_sync_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def test_with_copy_props(self):
]
)

def test_upload_with_flexible_checksum_sha1(self):
def test_upload_with_checksum_algorithm_sha1(self):
self.files.create_file('foo.txt', 'contents')
cmdline = (
'%s %s s3://bucket/ --checksum-algorithm SHA1' % (
Expand All @@ -369,7 +369,7 @@ def test_upload_with_flexible_checksum_sha1(self):
})
)

def test_upload_with_flexible_checksum_sha256(self):
def test_upload_with_checksum_algorithm_sha256(self):
self.files.create_file('foo.txt', 'contents')
cmdline = (
'%s %s s3://bucket/ --checksum-algorithm SHA256' % (
Expand All @@ -385,7 +385,7 @@ def test_upload_with_flexible_checksum_sha256(self):
})
)

def test_download_with_flexible_checksum_sha1(self):
def test_download_with_checksum_mode_sha1(self):
self.parsed_responses = [
self.head_object_response(),
{
Expand All @@ -401,7 +401,7 @@ def test_download_with_flexible_checksum_sha1(self):
self.run_cmd(cmdline, expected_rc=0)
self.assertEqual(self.operations_called[0][0].name, 'ListObjectsV2')

def test_download_with_flexible_checksum_sha256(self):
def test_download_with_checksum_mode_sha256(self):
self.parsed_responses = [
self.head_object_response(),
{
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/customizations/s3/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def test_upload_part_copy(self):
'SSECustomerKey': 'my-sse-c-key'})


class TestRequestParamsMapperFlexibleChecksumsUploads:
class TestRequestParamsMapperChecksumAlgorithm:
@pytest.fixture
def cli_params(self):
return {'checksum_algorithm': 'CRC32'}
Expand All @@ -669,7 +669,7 @@ def test_upload_part(self, cli_params):
assert request_params == {'ChecksumAlgorithm': 'CRC32'}


class TestRequestParamsMapperFlexibleChecksumsDownloads:
class TestRequestParamsMapperChecksumMode:
@pytest.fixture
def cli_params(self):
return {'checksum_mode': 'ENABLED'}
Expand Down

0 comments on commit 9515516

Please sign in to comment.