Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/test_testutils.py
1566 views
1
# Copyright 2013 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.testutils import mock
14
from awscli.testutils import create_bucket
15
from awscli.testutils import BaseCLIDriverTest
16
17
18
class TestCreateBucket(BaseCLIDriverTest):
19
def test_bucket_already_owned_by_you(self):
20
# TODO: fix this patch when we have a better way to stub out responses
21
with mock.patch('botocore.endpoint.Endpoint._send') as _send:
22
_send.side_effect = [
23
mock.Mock(status_code=500, headers={}, content=b''),
24
mock.Mock(
25
status_code=409, headers={},
26
content=b'''<?xml version="1.0" encoding="UTF-8"?>
27
<Error>
28
<Code>BucketAlreadyOwnedByYou</Code>
29
<Message>Your previous request to create the named
30
bucket succeeded and you already own it.</Message>
31
<BucketName>awscli-foo-bar</BucketName>
32
<RequestId>0123456789ABCDEF</RequestId>
33
<HostId>foo</HostId>
34
</Error>'''),
35
]
36
self.assertEqual(create_bucket(self.session, 'bucket'), 'bucket')
37
38