Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/s3/test_fileinfobuilder.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 mock
14
from awscli.testutils import unittest
15
from awscli.customizations.s3.filegenerator import FileStat
16
from awscli.customizations.s3.fileinfo import FileInfo
17
from awscli.customizations.s3.fileinfobuilder import FileInfoBuilder
18
19
20
class TestFileInfoBuilder(unittest.TestCase):
21
def test_info_setter(self):
22
info_setter = FileInfoBuilder(client='client',
23
source_client='source_client',
24
parameters='parameters',
25
is_stream='is_stream')
26
files = [FileStat(src='src', dest='dest', compare_key='compare_key',
27
size='size', last_update='last_update',
28
src_type='src_type', dest_type='dest_type',
29
operation_name='operation_name',
30
response_data='associated_response_data',
31
etag='etag',)]
32
file_infos = info_setter.call(files)
33
for file_info in file_infos:
34
attributes = file_info.__dict__.keys()
35
for key in attributes:
36
self.assertEqual(getattr(file_info, key), str(key))
37
38
def test_swaps_clients_for_sync_delete(self):
39
client_name = 'client'
40
source_client_name = 'source_client'
41
info_setter = FileInfoBuilder(client=client_name,
42
source_client=source_client_name,
43
parameters={'delete': True},
44
is_stream='is_stream')
45
files = [FileStat(src='src', dest='dest', compare_key='compare_key',
46
size='size', last_update='last_update',
47
src_type='src_type', dest_type='dest_type',
48
operation_name='delete')]
49
file_infos = info_setter.call(files)
50
for file_info in file_infos:
51
self.assertEqual(file_info.client, source_client_name)
52
self.assertEqual(file_info.source_client, client_name)
53
54
if __name__ == "__main__":
55
unittest.main()
56
57