From 9515516d5025a4dd54ba90eaa4d225123a9b394d Mon Sep 17 00:00:00 2001 From: aemous Date: Mon, 23 Sep 2024 13:32:12 -0400 Subject: [PATCH] Update test function and class names. Enable checksum-algorithm flag on copies. --- awscli/customizations/s3/subcommands.py | 8 ++++---- awscli/customizations/s3/utils.py | 1 - tests/functional/s3/test_cp_command.py | 8 ++++---- tests/functional/s3/test_mv_command.py | 4 ++-- tests/functional/s3/test_sync_command.py | 8 ++++---- tests/unit/customizations/s3/test_utils.py | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index 153fc7ddb317a..3b469dced2e01 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -1380,8 +1380,8 @@ 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': ' ', 's3s3': ' ', @@ -1389,8 +1389,8 @@ def _raise_if_paths_type_incorrect_for_param(self, param, paths_type, expected_p 's3': '' } 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): diff --git a/awscli/customizations/s3/utils.py b/awscli/customizations/s3/utils.py index d630302240c6f..d8dedb710f989 100644 --- a/awscli/customizations/s3/utils.py +++ b/awscli/customizations/s3/utils.py @@ -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): diff --git a/tests/functional/s3/test_cp_command.py b/tests/functional/s3/test_cp_command.py index e1f55ca069b0b..2fb9160b83d36 100644 --- a/tests/functional/s3/test_cp_command.py +++ b/tests/functional/s3/test_cp_command.py @@ -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' % ( @@ -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' % ( @@ -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(), { @@ -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(), { diff --git a/tests/functional/s3/test_mv_command.py b/tests/functional/s3/test_mv_command.py index 36ea50318df6e..ae6d4dfcb7bb0 100644 --- a/tests/functional/s3/test_mv_command.py +++ b/tests/functional/s3/test_mv_command.py @@ -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' % ( @@ -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(), { diff --git a/tests/functional/s3/test_sync_command.py b/tests/functional/s3/test_sync_command.py index 28d69010260a0..556ae533aef40 100644 --- a/tests/functional/s3/test_sync_command.py +++ b/tests/functional/s3/test_sync_command.py @@ -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' % ( @@ -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' % ( @@ -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(), { @@ -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(), { diff --git a/tests/unit/customizations/s3/test_utils.py b/tests/unit/customizations/s3/test_utils.py index f4fa5ee489073..7435f69872b42 100644 --- a/tests/unit/customizations/s3/test_utils.py +++ b/tests/unit/customizations/s3/test_utils.py @@ -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'} @@ -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'}