Path: blob/develop/tests/unit/customizations/s3/test_fileinfo.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 unittest13from awscli.customizations.s3.fileinfo import FileInfo141516class TestIsGlacierCompatible(unittest.TestCase):17def setUp(self):18self.file_info = FileInfo('bucket/key')19self.file_info.associated_response_data = {'StorageClass': 'GLACIER'}2021def test_operation_is_glacier_compatible(self):22self.file_info.operation_name = 'delete'23self.assertTrue(self.file_info.is_glacier_compatible())2425def test_download_operation_is_not_glacier_compatible(self):26self.file_info.operation_name = 'download'27self.assertFalse(self.file_info.is_glacier_compatible())2829def test_copy_operation_is_not_glacier_compatible(self):30self.file_info.operation_name = 'copy'31self.assertFalse(self.file_info.is_glacier_compatible())3233def test_operation_is_glacier_compatible_for_non_glacier(self):34self.file_info.operation_name = 'download'35self.file_info.associated_response_data = {'StorageClass': 'STANDARD'}36self.assertTrue(self.file_info.is_glacier_compatible())3738def test_move_operation_is_not_glacier_compatible_for_s3_source(self):39self.file_info.operation_name = 'move'40self.file_info.src_type = 's3'41self.assertFalse(self.file_info.is_glacier_compatible())4243def test_move_operation_is_glacier_compatible_for_local_source(self):44self.file_info.operation_name = 'move'45self.file_info.src_type = 'local'46self.assertTrue(self.file_info.is_glacier_compatible())4748def test_response_is_not_glacier(self):49self.file_info.associated_response_data = {'StorageClass': 'STANDARD'}50self.assertTrue(self.file_info.is_glacier_compatible())5152def test_response_missing_storage_class(self):53self.file_info.associated_response_data = {'Key': 'Foo'}54self.assertTrue(self.file_info.is_glacier_compatible())5556def test_restored_object_is_glacier_compatible(self):57self.file_info.operation_name = 'download'58self.file_info.associated_response_data = {59'StorageClass': 'GLACIER',60'Restore': 'ongoing-request="false", expiry-date="..."'61}62self.assertTrue(self.file_info.is_glacier_compatible())6364def test_ongoing_restore_is_not_glacier_compatible(self):65self.file_info.operation_name = 'download'66self.file_info.associated_response_data = {67'StorageClass': 'GLACIER',68'Restore': 'ongoing-request="true", expiry-date="..."'69}70self.assertFalse(self.file_info.is_glacier_compatible())717273