From 7c92aed40ca782cbd2edbfb6ce773650de8a73af Mon Sep 17 00:00:00 2001 From: wingkwong Date: Tue, 11 Feb 2020 17:46:50 +0800 Subject: [PATCH] #4832 Add --include --exclude to aws s3 ls test case --- .../customizations/s3/test_subcommands.py | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/unit/customizations/s3/test_subcommands.py b/tests/unit/customizations/s3/test_subcommands.py index a4418a79dae4..12e42c31c91c 100644 --- a/tests/unit/customizations/s3/test_subcommands.py +++ b/tests/unit/customizations/s3/test_subcommands.py @@ -95,7 +95,7 @@ def test_ls_command_for_bucket(self): ls_command = ListCommand(self.session) parsed_args = FakeArgs(paths='s3://mybucket/', dir_op=False, page_size='5', human_readable=False, - summarize=False, request_payer=None) + summarize=False, request_payer=None, filters=[['--include', '*']]) parsed_globals = mock.Mock() ls_command._run_main(parsed_args, parsed_globals) call = self.session.create_client.return_value.list_objects_v2 @@ -118,7 +118,7 @@ def test_ls_command_with_no_args(self): verify_ssl=None) parsed_args = FakeArgs(dir_op=False, paths='s3://', human_readable=False, summarize=False, - request_payer=None) + request_payer=None, filters=[['--include', '*']]) ls_command._run_main(parsed_args, parsed_global) # We should only be a single call. call = self.session.create_client.return_value.list_buckets @@ -139,7 +139,7 @@ def test_ls_with_verify_argument(self): verify_ssl=False) parsed_args = FakeArgs(paths='s3://', dir_op=False, human_readable=False, summarize=False, - request_payer=None) + request_payer=None, filters=[['--include', '*']]) ls_command._run_main(parsed_args, parsed_global) # Verify get_client get_client = self.session.create_client @@ -152,7 +152,7 @@ def test_ls_with_requester_pays(self): ls_command = ListCommand(self.session) parsed_args = FakeArgs(paths='s3://mybucket/', dir_op=False, human_readable=False, summarize=False, - request_payer='requester', page_size='5') + request_payer='requester', page_size='5', filters=[['--include', '*']]) parsed_globals = mock.Mock() ls_command._run_main(parsed_args, parsed_globals) call = self.session.create_client.return_value.list_objects @@ -171,6 +171,19 @@ def test_ls_with_requester_pays(self): paginate.assert_called_with(**ref_call_args) + def test_ls_with_filters(self): + ls_command = ListCommand(self.session) + parsed_global = FakeArgs(region='us-west-2', endpoint_url=None, + verify_ssl=False) + parsed_args = FakeArgs(paths='s3://', dir_op=False, + human_readable=False, summarize=False, + request_payer=None, filters=[['--include', '*']]) + ls_command._run_main(parsed_args, parsed_global) + get_client = self.session.create_client + args = get_client.call_args + self.assertEqual(args, mock.call( + 's3', region_name='us-west-2', endpoint_url=None, verify=False, + config=None)) class CommandArchitectureTest(BaseAWSCommandParamsTest): def setUp(self):