Path: blob/develop/tests/unit/customizations/s3/test_fileinfobuilder.py
1569 views
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12from awscli.testutils import mock13from awscli.testutils import unittest14from awscli.customizations.s3.filegenerator import FileStat15from awscli.customizations.s3.fileinfo import FileInfo16from awscli.customizations.s3.fileinfobuilder import FileInfoBuilder171819class TestFileInfoBuilder(unittest.TestCase):20def test_info_setter(self):21info_setter = FileInfoBuilder(client='client',22source_client='source_client',23parameters='parameters',24is_stream='is_stream')25files = [FileStat(src='src', dest='dest', compare_key='compare_key',26size='size', last_update='last_update',27src_type='src_type', dest_type='dest_type',28operation_name='operation_name',29response_data='associated_response_data',30etag='etag',)]31file_infos = info_setter.call(files)32for file_info in file_infos:33attributes = file_info.__dict__.keys()34for key in attributes:35self.assertEqual(getattr(file_info, key), str(key))3637def test_swaps_clients_for_sync_delete(self):38client_name = 'client'39source_client_name = 'source_client'40info_setter = FileInfoBuilder(client=client_name,41source_client=source_client_name,42parameters={'delete': True},43is_stream='is_stream')44files = [FileStat(src='src', dest='dest', compare_key='compare_key',45size='size', last_update='last_update',46src_type='src_type', dest_type='dest_type',47operation_name='delete')]48file_infos = info_setter.call(files)49for file_info in file_infos:50self.assertEqual(file_info.client, source_client_name)51self.assertEqual(file_info.source_client, client_name)5253if __name__ == "__main__":54unittest.main()555657