Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/s3/test_fileinfo.py
1569 views
1
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
from awscli.testutils import unittest
14
from awscli.customizations.s3.fileinfo import FileInfo
15
16
17
class TestIsGlacierCompatible(unittest.TestCase):
18
def setUp(self):
19
self.file_info = FileInfo('bucket/key')
20
self.file_info.associated_response_data = {'StorageClass': 'GLACIER'}
21
22
def test_operation_is_glacier_compatible(self):
23
self.file_info.operation_name = 'delete'
24
self.assertTrue(self.file_info.is_glacier_compatible())
25
26
def test_download_operation_is_not_glacier_compatible(self):
27
self.file_info.operation_name = 'download'
28
self.assertFalse(self.file_info.is_glacier_compatible())
29
30
def test_copy_operation_is_not_glacier_compatible(self):
31
self.file_info.operation_name = 'copy'
32
self.assertFalse(self.file_info.is_glacier_compatible())
33
34
def test_operation_is_glacier_compatible_for_non_glacier(self):
35
self.file_info.operation_name = 'download'
36
self.file_info.associated_response_data = {'StorageClass': 'STANDARD'}
37
self.assertTrue(self.file_info.is_glacier_compatible())
38
39
def test_move_operation_is_not_glacier_compatible_for_s3_source(self):
40
self.file_info.operation_name = 'move'
41
self.file_info.src_type = 's3'
42
self.assertFalse(self.file_info.is_glacier_compatible())
43
44
def test_move_operation_is_glacier_compatible_for_local_source(self):
45
self.file_info.operation_name = 'move'
46
self.file_info.src_type = 'local'
47
self.assertTrue(self.file_info.is_glacier_compatible())
48
49
def test_response_is_not_glacier(self):
50
self.file_info.associated_response_data = {'StorageClass': 'STANDARD'}
51
self.assertTrue(self.file_info.is_glacier_compatible())
52
53
def test_response_missing_storage_class(self):
54
self.file_info.associated_response_data = {'Key': 'Foo'}
55
self.assertTrue(self.file_info.is_glacier_compatible())
56
57
def test_restored_object_is_glacier_compatible(self):
58
self.file_info.operation_name = 'download'
59
self.file_info.associated_response_data = {
60
'StorageClass': 'GLACIER',
61
'Restore': 'ongoing-request="false", expiry-date="..."'
62
}
63
self.assertTrue(self.file_info.is_glacier_compatible())
64
65
def test_ongoing_restore_is_not_glacier_compatible(self):
66
self.file_info.operation_name = 'download'
67
self.file_info.associated_response_data = {
68
'StorageClass': 'GLACIER',
69
'Restore': 'ongoing-request="true", expiry-date="..."'
70
}
71
self.assertFalse(self.file_info.is_glacier_compatible())
72
73