Beispiel #1
0
 def test_ls_command_with_no_args(self):
     ls_command = ListCommand(self.session)
     parsed_global = FakeArgs(region=None,
                              endpoint_url=None,
                              verify_ssl=None)
     parsed_args = FakeArgs(dir_op=False,
                            paths='s3://',
                            human_readable=False,
                            summarize=False)
     ls_command._run_main(parsed_args, parsed_global)
     # We should only be a single call.
     call = self.session.create_client.return_value.list_buckets
     self.assertTrue(call.called)
     self.assertEqual(call.call_count, 1)
     self.assertEqual(call.call_args[1], {})
     # Verify get_client
     get_client = self.session.create_client
     args = get_client.call_args
     self.assertEqual(
         args,
         mock.call('s3',
                   region_name=None,
                   endpoint_url=None,
                   verify=None,
                   config=None))
Beispiel #2
0
    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)
        parsed_globals = mock.Mock()
        ls_command._run_main(parsed_args, parsed_globals)
        call = self.session.create_client.return_value.list_objects
        paginate = self.session.create_client.return_value.get_paginator\
            .return_value.paginate
        # We should make no operation calls.
        self.assertEqual(call.call_count, 0)
        # And only a single pagination call to ListObjects.
        self.session.create_client.return_value.get_paginator.\
            assert_called_with('list_objects')
        ref_call_args = {
            'Bucket': u'mybucket',
            'Delimiter': '/',
            'Prefix': u'',
            'PaginationConfig': {
                'PageSize': u'5'
            }
        }

        paginate.assert_called_with(**ref_call_args)
Beispiel #3
0
 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)
     parsed_globals = mock.Mock()
     ls_command._run_main(parsed_args, parsed_globals)
     call = self.session.get_service.return_value.get_operation\
             .return_value.call
     paginate = self.session.get_service.return_value.get_operation\
             .return_value.paginate
     # We should make no operation calls.
     self.assertEqual(call.call_count, 0)
     # And only a single pagination call to ListObjects.
     self.session.get_service.return_value.get_operation.assert_called_with(
         'ListObjects')
     self.assertEqual(
         paginate.call_args[1], {
             'bucket': u'mybucket',
             'delimiter': '/',
             'prefix': u'',
             'page_size': u'5'
         })
Beispiel #4
0
 def test_ls_with_verify_argument(self):
     options = {'default': 's3://', 'nargs': '?'}
     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)
     ls_command._run_main(parsed_args, parsed_global)
     # Verify get_endpoint
     get_endpoint = self.session.get_service.return_value.get_endpoint
     args = get_endpoint.call_args
     self.assertEqual(args, mock.call(region_name='us-west-2',
                                      endpoint_url=None,
                                      verify=False))
Beispiel #5
0
 def test_ls_with_verify_argument(self):
     options = {'default': 's3://', 'nargs': '?'}
     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)
     ls_command._run_main(parsed_args, parsed_global)
     # Verify get_client
     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))
 def test_ls_with_verify_argument(self):
     options = {'default': 's3://', 'nargs': '?'}
     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)
     ls_command._run_main(parsed_args, parsed_global)
     # Verify get_endpoint
     get_endpoint = self.session.get_service.return_value.get_endpoint
     args = get_endpoint.call_args
     self.assertEqual(args, mock.call(region_name='us-west-2',
                                      endpoint_url=None,
                                      verify=False))
Beispiel #7
0
 def test_ls_command_for_bucket(self):
     ls_command = ListCommand(self.session)
     parsed_args = FakeArgs(paths='s3://mybucket/', dir_op=False)
     ls_command._run_main(parsed_args, mock.Mock())
     call = self.session.get_service.return_value.get_operation\
             .return_value.call
     paginate = self.session.get_service.return_value.get_operation\
             .return_value.paginate
     # We should make no operation calls.
     self.assertEqual(call.call_count, 0)
     # And only a single pagination call to ListObjects.
     self.session.get_service.return_value.get_operation.assert_called_with(
         'ListObjects')
     self.assertEqual(
         paginate.call_args[1], {'bucket': u'mybucket',
                                 'delimiter': '/', 'prefix': u''})
Beispiel #8
0
 def test_ls_command_with_no_args(self):
     ls_command = ListCommand(self.session)
     parsed_global = FakeArgs(region=None, endpoint_url=None, verify_ssl=None)
     parsed_args = FakeArgs(dir_op=False, paths='s3://')
     ls_command._run_main(parsed_args, parsed_global)
     # We should only be a single call.
     self.session.get_service.return_value.get_operation.assert_called_with(
         'ListBuckets')
     call = self.session.get_service.return_value.get_operation\
             .return_value.call
     self.assertEqual(call.call_count, 1)
     self.assertEqual(call.call_args[1], {})
     # Verify get_endpoint
     get_endpoint = self.session.get_service.return_value.get_endpoint
     args = get_endpoint.call_args
     self.assertEqual(args, mock.call(region_name=None, endpoint_url=None,
                                      verify=None))
Beispiel #9
0
 def test_ls_command_with_no_args(self):
     ls_command = ListCommand(self.session)
     parsed_global = FakeArgs(region=None, endpoint_url=None,
                              verify_ssl=None)
     parsed_args = FakeArgs(dir_op=False, paths='s3://',
                            human_readable=False, summarize=False)
     ls_command._run_main(parsed_args, parsed_global)
     # We should only be a single call.
     call = self.session.create_client.return_value.list_buckets
     self.assertTrue(call.called)
     self.assertEqual(call.call_count, 1)
     self.assertEqual(call.call_args[1], {})
     # Verify get_client
     get_client = self.session.create_client
     args = get_client.call_args
     self.assertEqual(args, mock.call('s3', region_name=None,
                                      endpoint_url=None, verify=None))
 def test_ls_command_with_no_args(self):
     ls_command = ListCommand(self.session)
     parsed_global = FakeArgs(region=None, endpoint_url=None, verify_ssl=None)
     parsed_args = FakeArgs(dir_op=False, paths='s3://')
     ls_command._run_main(parsed_args, parsed_global)
     # We should only be a single call.
     self.session.get_service.return_value.get_operation.assert_called_with(
         'ListBuckets')
     call = self.session.get_service.return_value.get_operation\
             .return_value.call
     self.assertEqual(call.call_count, 1)
     self.assertEqual(call.call_args[1], {})
     # Verify get_endpoint
     get_endpoint = self.session.get_service.return_value.get_endpoint
     args = get_endpoint.call_args
     self.assertEqual(args, mock.call(region_name=None, endpoint_url=None,
                                      verify=None))
Beispiel #11
0
    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)
        parsed_globals = mock.Mock()
        ls_command._run_main(parsed_args, parsed_globals)
        call = self.session.create_client.return_value.list_objects
        paginate = self.session.create_client.return_value.get_paginator\
            .return_value.paginate
        # We should make no operation calls.
        self.assertEqual(call.call_count, 0)
        # And only a single pagination call to ListObjects.
        self.session.create_client.return_value.get_paginator.\
            assert_called_with('list_objects')
        ref_call_args = {'Bucket': u'mybucket', 'Delimiter': '/',
                         'Prefix': u'', 'page_size': u'5'}

        paginate.assert_called_with(**ref_call_args)