Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/s3/test_rm_command.py
1567 views
1
# Copyright 2017 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 tests.functional.s3 import BaseS3TransferCommandTest
14
15
16
class TestRmCommand(BaseS3TransferCommandTest):
17
prefix = 's3 rm'
18
19
def test_operations_used(self):
20
cmdline = '%s s3://bucket/key.txt' % self.prefix
21
self.run_cmd(cmdline, expected_rc=0)
22
# The only operation we should have called is DeleteObject.
23
self.assertEqual(
24
len(self.operations_called), 1, self.operations_called)
25
self.assertEqual(self.operations_called[0][0].name, 'DeleteObject')
26
27
def test_delete_with_request_payer(self):
28
cmdline = '%s s3://mybucket/mykey --request-payer' % self.prefix
29
self.run_cmd(cmdline, expected_rc=0)
30
self.assert_operations_called(
31
[
32
('DeleteObject', {
33
'Bucket': 'mybucket',
34
'Key': 'mykey',
35
'RequestPayer': 'requester'
36
})
37
]
38
39
)
40
41
def test_recursive_delete_with_requests(self):
42
cmdline = '%s s3://mybucket/ --recursive --request-payer' % self.prefix
43
self.parsed_responses = [
44
self.list_objects_response(['mykey']),
45
self.empty_response(),
46
]
47
self.run_cmd(cmdline, expected_rc=0)
48
self.assert_operations_called(
49
[
50
self.list_objects_request(
51
'mybucket', RequestPayer='requester'),
52
self.delete_object_request(
53
'mybucket', 'mykey', RequestPayer='requester'),
54
]
55
56
)
57
58