Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests for TransferManager.shutdown() #253

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion s3transfer/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def shutdown(self, cancel=False, cancel_msg=''):
:param cancel_msg: The message to specify if canceling all in-progress
transfers.
"""
self._shutdown(cancel, cancel, cancel_msg)
self._shutdown(cancel, cancel_msg)

def _shutdown(self, cancel, cancel_msg, exc_type=CancelledError):
if cancel:
Expand Down
33 changes: 33 additions & 0 deletions tests/integration/test_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
from unittest import TestCase, mock

from s3transfer.exceptions import CancelledError
from s3transfer.futures import TransferCoordinator
from s3transfer.manager import TransferManager


class TestTransferManager(TestCase):
def test_shutdown_cancels_transfer_coordinator(self):
client = mock.Mock()

cancel_msg = 'Test message'

transfer_manager = TransferManager(client)
transfer_coordinator = TransferCoordinator()
coordinator_controller = transfer_manager.coordinator_controller
coordinator_controller.add_transfer_coordinator(transfer_coordinator)
transfer_manager.shutdown(True, cancel_msg)

self.assertIsInstance(transfer_coordinator.exception, CancelledError)
self.assertEqual(str(transfer_coordinator.exception), cancel_msg)