Closed
Description
Test cases written in moto makes actual AWS API calls to botocore instead of mocking them. This happens with the latest version of boto3 (1.8.). It used to work fine without issues with 1.7. versions.
Sample code to reproduce error
import boto3
import json
from moto import mock_s3
@mock_s3
def test_mock_s3():
client = boto3.client('s3', region_name='us-east-1')
client.create_bucket(Bucket='testbucket')
response = client.list_buckets()
print json.dumps(response, default=str)
if __name__ == "__main__":
test_mock_s3()
Expected result
Method should return the ListBuckets
response. It should look something like:
{"Owner": {"DisplayName": "webfile", "ID": "bcaf1ffd86f41161ca5fb16fd081034f"}, "Buckets": [{"CreationDate": "2006-02-03 16:45:09+00:00", "Name": "testbucket"}], "ResponseMetadata": {"RetryAttempts": 0, "HTTPStatusCode": 200, "HTTPHeaders": {"Content-Type": "text/plain"}}}
Actual error
botocore.errorfactory.BucketAlreadyExists: An error occurred (BucketAlreadyExists) when calling the CreateBucket operation: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
Full stack trace
Traceback (most recent call last):
File "testcases.py", line 14, in <module>
test_mock_s3()
File "/private/tmp/virtualenv2/lib/python2.7/site-packages/moto/core/models.py", line 71, in wrapper
result = func(*args, **kwargs)
File "testcases.py", line 8, in test_mock_s3
client.create_bucket(Bucket='testbucket')
File "/private/tmp/virtualenv2/lib/python2.7/site-packages/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/private/tmp/virtualenv2/lib/python2.7/site-packages/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.BucketAlreadyExists: An error occurred (BucketAlreadyExists) when calling the CreateBucket operation: The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a different name and try again.
Library versions
moto : 1.3.4
boto3 : 1.8.1 - fails
boto3 : 1.7.84 - succeeds
Metadata
Metadata
Assignees
Labels
No labels