S3 Mock should return an HTTP 409 if trying to create a bucket that
already exists. Closes #94.
This commit is contained in:
parent
76553671f2
commit
60cd79c6e2
6 changed files with 33 additions and 16 deletions
|
|
@ -2,7 +2,7 @@ import urllib2
|
|||
from io import BytesIO
|
||||
|
||||
import boto
|
||||
from boto.exception import S3ResponseError
|
||||
from boto.exception import S3CreateError, S3ResponseError
|
||||
from boto.s3.key import Key
|
||||
from freezegun import freeze_time
|
||||
import requests
|
||||
|
|
@ -171,6 +171,14 @@ def test_bucket_with_dash():
|
|||
conn.get_bucket.when.called_with('mybucket-test').should.throw(S3ResponseError)
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_create_existing_bucket():
|
||||
"Trying to create a bucket that already exists should raise an Error"
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
conn.create_bucket("foobar")
|
||||
conn.create_bucket.when.called_with('foobar').should.throw(S3CreateError)
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_bucket_deletion():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
|
|
|
|||
|
|
@ -20,20 +20,20 @@ def test_s3_server_bucket_create():
|
|||
backend = server.create_backend_app("s3")
|
||||
test_client = backend.test_client()
|
||||
|
||||
res = test_client.put('/', 'http://foobar.localhost:5000/')
|
||||
res = test_client.put('/', 'http://foobaz.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
res = test_client.get('/')
|
||||
res.data.should.contain('<Name>foobar</Name>')
|
||||
res.data.should.contain('<Name>foobaz</Name>')
|
||||
|
||||
res = test_client.get('/', 'http://foobar.localhost:5000/')
|
||||
res = test_client.get('/', 'http://foobaz.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.contain("ListBucketResult")
|
||||
|
||||
res = test_client.put('/bar', 'http://foobar.localhost:5000/', data='test value')
|
||||
res = test_client.put('/bar', 'http://foobaz.localhost:5000/', data='test value')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
res = test_client.get('/bar', 'http://foobar.localhost:5000/')
|
||||
res = test_client.get('/bar', 'http://foobaz.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal("test value")
|
||||
|
||||
|
|
@ -42,14 +42,14 @@ def test_s3_server_post_to_bucket():
|
|||
backend = server.create_backend_app("s3")
|
||||
test_client = backend.test_client()
|
||||
|
||||
res = test_client.put('/', 'http://foobar.localhost:5000/')
|
||||
res = test_client.put('/', 'http://tester.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
test_client.post('/', "https://foobar.localhost:5000/", data={
|
||||
test_client.post('/', "https://tester.localhost:5000/", data={
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
|
||||
res = test_client.get('/the-key', 'http://foobar.localhost:5000/')
|
||||
res = test_client.get('/the-key', 'http://tester.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal("nothing")
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ def test_s3_server_post_to_bucket():
|
|||
backend = server.create_backend_app("s3bucket_path")
|
||||
test_client = backend.test_client()
|
||||
|
||||
res = test_client.put('/foobar', 'http://localhost:5000/')
|
||||
res = test_client.put('/foobar2', 'http://localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
test_client.post('/foobar', "https://localhost:5000/", data={
|
||||
test_client.post('/foobar2', "https://localhost:5000/", data={
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
|
||||
res = test_client.get('/foobar/the-key', 'http://localhost:5000/')
|
||||
res = test_client.get('/foobar2/the-key', 'http://localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal("nothing")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue