File size: 2,184 Bytes
065fee7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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 s3transfer.delete import DeleteObjectTask
from tests import BaseTaskTest
class TestDeleteObjectTask(BaseTaskTest):
def setUp(self):
super().setUp()
self.bucket = 'mybucket'
self.key = 'mykey'
self.extra_args = {}
self.callbacks = []
def get_delete_task(self, **kwargs):
default_kwargs = {
'client': self.client,
'bucket': self.bucket,
'key': self.key,
'extra_args': self.extra_args,
}
default_kwargs.update(kwargs)
return self.get_task(DeleteObjectTask, main_kwargs=default_kwargs)
def test_main(self):
self.stubber.add_response(
'delete_object',
service_response={},
expected_params={
'Bucket': self.bucket,
'Key': self.key,
},
)
task = self.get_delete_task()
task()
self.stubber.assert_no_pending_responses()
def test_extra_args(self):
self.extra_args['MFA'] = 'mfa-code'
self.extra_args['VersionId'] = '12345'
self.stubber.add_response(
'delete_object',
service_response={},
expected_params={
'Bucket': self.bucket,
'Key': self.key,
# These extra_args should be injected into the
# expected params for the delete_object call.
'MFA': 'mfa-code',
'VersionId': '12345',
},
)
task = self.get_delete_task()
task()
self.stubber.assert_no_pending_responses()
|