Path: blob/develop/tests/unit/customizations/s3/syncstrategy/test_register.py
2634 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.customizations.s3.syncstrategy.register import \13register_sync_strategy14from awscli.testutils import mock, unittest151617class TestRegisterSyncStrategy(unittest.TestCase):18def setUp(self):19self.session = mock.Mock()20self.strategy_cls = mock.Mock()21self.strategy_object = mock.Mock()22self.strategy_cls.return_value = self.strategy_object2324def test_register_sync_strategy(self):25"""26Ensure that registering a single strategy class works as expected27when ``sync_type`` is specified.28"""29register_sync_strategy(self.session, self.strategy_cls, 'sync_type')30# Ensure sync strategy class is instantiated31self.strategy_cls.assert_called_with('sync_type')32# Ensure the sync strategy's ``register_strategy`` method is33# called correctly.34self.strategy_object.register_strategy.assert_called_with(self.session)3536def test_register_sync_strategy_default_sync_type(self):37"""38Ensure that registering a single strategy class works as expected39when the ``sync_type`` is not specified.40"""41register_sync_strategy(self.session, self.strategy_cls)42# Ensure sync strategy class is instantiated43self.strategy_cls.assert_called_with('file_at_src_and_dest')44# Ensure the sync strategy's ``register_strategy`` method is45# called correctly.46self.strategy_object.register_strategy.assert_called_with(self.session)474849if __name__ == "__main__":50unittest.main()515253