Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/s3/syncstrategy/test_register.py
2634 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.customizations.s3.syncstrategy.register import \
14
register_sync_strategy
15
from awscli.testutils import mock, unittest
16
17
18
class TestRegisterSyncStrategy(unittest.TestCase):
19
def setUp(self):
20
self.session = mock.Mock()
21
self.strategy_cls = mock.Mock()
22
self.strategy_object = mock.Mock()
23
self.strategy_cls.return_value = self.strategy_object
24
25
def test_register_sync_strategy(self):
26
"""
27
Ensure that registering a single strategy class works as expected
28
when ``sync_type`` is specified.
29
"""
30
register_sync_strategy(self.session, self.strategy_cls, 'sync_type')
31
# Ensure sync strategy class is instantiated
32
self.strategy_cls.assert_called_with('sync_type')
33
# Ensure the sync strategy's ``register_strategy`` method is
34
# called correctly.
35
self.strategy_object.register_strategy.assert_called_with(self.session)
36
37
def test_register_sync_strategy_default_sync_type(self):
38
"""
39
Ensure that registering a single strategy class works as expected
40
when the ``sync_type`` is not specified.
41
"""
42
register_sync_strategy(self.session, self.strategy_cls)
43
# Ensure sync strategy class is instantiated
44
self.strategy_cls.assert_called_with('file_at_src_and_dest')
45
# Ensure the sync strategy's ``register_strategy`` method is
46
# called correctly.
47
self.strategy_object.register_strategy.assert_called_with(self.session)
48
49
50
if __name__ == "__main__":
51
unittest.main()
52
53