From 8eb168d0ef235ccb08b0c51637ddaab7d3a4adcd Mon Sep 17 00:00:00 2001 From: aemous Date: Tue, 1 Oct 2024 15:44:11 -0400 Subject: [PATCH] Made updates according to feedback. --- .changes/next-release/feature-s3-46667.json | 2 +- awscli/customizations/s3/subcommands.py | 2 +- tests/unit/customizations/s3/test_subcommands.py | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.changes/next-release/feature-s3-46667.json b/.changes/next-release/feature-s3-46667.json index 9dc4fd3c81c6..8d1d36b64f23 100644 --- a/.changes/next-release/feature-s3-46667.json +++ b/.changes/next-release/feature-s3-46667.json @@ -1,5 +1,5 @@ { "type": "feature", "category": "s3", - "description": "Adds support for checksums other than MD5 to high-level S3 commands." + "description": "Adds ``--checksum-mode`` and ``--checksum-algorithm`` parameters to high-level ``s3`` commands." } diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index 3b469dced2e0..9a49d4c9d197 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -1390,7 +1390,7 @@ def _raise_if_paths_type_incorrect_for_param(self, param, paths_type, allowed_pa } raise ParamValidationError( f"Expected {param} parameter to be used with one of following path formats: " - f"{', '.join(allowed_paths)} but received {expected_usage_map[paths_type]}" + f"{', '.join([expected_usage_map[path] for path in allowed_paths])}. Instead, received {expected_usage_map[paths_type]}." ) def _normalize_s3_trailing_slash(self, paths): diff --git a/tests/unit/customizations/s3/test_subcommands.py b/tests/unit/customizations/s3/test_subcommands.py index d74bfd862896..fda78f5d26c6 100644 --- a/tests/unit/customizations/s3/test_subcommands.py +++ b/tests/unit/customizations/s3/test_subcommands.py @@ -412,29 +412,33 @@ def test_validate_checksum_algorithm_sync_download_error(self): paths = ['s3://bucket/key', self.file_creator.rootdir] parameters = {'checksum_algorithm': 'CRC32C'} cmd_params = CommandParameters('sync', parameters, '') - with self.assertRaises(ParamValidationError): + with self.assertRaises(ParamValidationError) as cm: cmd_params.add_paths(paths) + self.assertIn('Expected checksum-algorithm parameter to be used with one of following path formats', cm.msg) def test_validate_checksum_mode_upload_error(self): paths = [self.file_creator.rootdir, 's3://bucket/key'] parameters = {'checksum_mode': 'ENABLED'} cmd_params = CommandParameters('cp', parameters, '') - with self.assertRaises(ParamValidationError): + with self.assertRaises(ParamValidationError) as cm: cmd_params.add_paths(paths) + self.assertIn('Expected checksum-mode parameter to be used with one of following path formats', cm.msg) def test_validate_checksum_mode_sync_upload_error(self): paths = [self.file_creator.rootdir, 's3://bucket/key'] parameters = {'checksum_mode': 'ENABLED'} cmd_params = CommandParameters('sync', parameters, '') - with self.assertRaises(ParamValidationError): + with self.assertRaises(ParamValidationError) as cm: cmd_params.add_paths(paths) + self.assertIn('Expected checksum-mode parameter to be used with one of following path formats', cm.msg) def test_validate_checksum_mode_move_error(self): paths = ['s3://bucket/key', 's3://bucket2/key'] parameters = {'checksum_mode': 'ENABLED'} cmd_params = CommandParameters('mv', parameters, '') - with self.assertRaises(ParamValidationError): + with self.assertRaises(ParamValidationError) as cm: cmd_params.add_paths(paths) + self.assertIn('Expected checksum-mode parameter to be used with one of following path formats', cm.msg) def test_validate_streaming_paths_error(self): parameters = {'src': '-', 'dest': 's3://bucket'}