cleanup code.

This commit is contained in:
Steve Pulec 2015-11-27 14:43:03 -05:00
commit 0df03ba409
9 changed files with 47 additions and 92 deletions

View file

@ -961,6 +961,16 @@ def test_boto3_bucket_create():
s3.Object('blah', 'hello.txt').get()['Body'].read().decode("utf-8").should.equal("some text")
@mock_s3
def test_boto3_bucket_create_eu_central():
s3 = boto3.resource('s3', region_name='eu-central-1')
s3.create_bucket(Bucket="blah")
s3.Object('blah', 'hello.txt').put(Body="some text")
s3.Object('blah', 'hello.txt').get()['Body'].read().decode("utf-8").should.equal("some text")
@mock_s3
def test_boto3_head_object():
s3 = boto3.resource('s3', region_name='us-east-1')

View file

@ -7,14 +7,12 @@ import moto.server as server
Test the different server responses
'''
HEADERS = {'host': 's3.amazonaws.com'}
def test_s3_server_get():
backend = server.create_backend_app("s3bucket_path")
test_client = backend.test_client()
res = test_client.get('/', headers=HEADERS)
res = test_client.get('/')
res.data.should.contain(b'ListAllMyBucketsResult')
@ -23,23 +21,23 @@ def test_s3_server_bucket_create():
backend = server.create_backend_app("s3bucket_path")
test_client = backend.test_client()
res = test_client.put('/foobar/', 'http://localhost:5000', headers=HEADERS)
res = test_client.put('/foobar/', 'http://localhost:5000')
res.status_code.should.equal(200)
res = test_client.get('/', headers=HEADERS)
res = test_client.get('/')
res.data.should.contain(b'<Name>foobar</Name>')
res = test_client.get('/foobar/', 'http://localhost:5000', headers=HEADERS)
res = test_client.get('/foobar/', 'http://localhost:5000')
res.status_code.should.equal(200)
res.data.should.contain(b"ListBucketResult")
res = test_client.get('/missing-bucket/', 'http://localhost:5000', headers=HEADERS)
res = test_client.get('/missing-bucket/', 'http://localhost:5000')
res.status_code.should.equal(404)
res = test_client.put('/foobar/bar/', 'http://localhost:5000', data='test value', headers=HEADERS)
res = test_client.put('/foobar/bar/', 'http://localhost:5000', data='test value')
res.status_code.should.equal(200)
res = test_client.get('/foobar/bar/', 'http://localhost:5000', headers=HEADERS)
res = test_client.get('/foobar/bar/', 'http://localhost:5000')
res.status_code.should.equal(200)
res.data.should.equal(b"test value")
@ -48,14 +46,14 @@ def test_s3_server_post_to_bucket():
backend = server.create_backend_app("s3bucket_path")
test_client = backend.test_client()
res = test_client.put('/foobar2/', 'http://localhost:5000/', headers=HEADERS)
res = test_client.put('/foobar2/', 'http://localhost:5000/')
res.status_code.should.equal(200)
test_client.post('/foobar2/', "https://localhost:5000/", data={
'key': 'the-key',
'file': 'nothing'
}, headers=HEADERS)
})
res = test_client.get('/foobar2/the-key/', 'http://localhost:5000/', headers=HEADERS)
res = test_client.get('/foobar2/the-key/', 'http://localhost:5000/')
res.status_code.should.equal(200)
res.data.should.equal(b"nothing")