more s3 tests for posting
This commit is contained in:
parent
9f19662d1c
commit
3bc975188f
3 changed files with 25 additions and 9 deletions
|
|
@ -101,7 +101,8 @@ def test_copy_key():
|
|||
|
||||
bucket.get_key("the-key").get_contents_as_string().should.equal("some value")
|
||||
bucket.get_key("new-key").get_contents_as_string().should.equal("some value")
|
||||
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_set_metadata():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
|
|
@ -113,6 +114,7 @@ def test_set_metadata():
|
|||
|
||||
bucket.get_key('the-key').get_metadata('md').should.equal('Metadatastring')
|
||||
|
||||
|
||||
@freeze_time("2012-01-01 12:00:00")
|
||||
@mock_s3
|
||||
def test_last_modified():
|
||||
|
|
@ -177,19 +179,20 @@ def test_get_all_buckets():
|
|||
def test_post_to_bucket():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
||||
|
||||
requests.post("https://foobar.s3.amazonaws.com/", {
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
|
||||
bucket.get_key('the-key').get_contents_as_string().should.equal('nothing')
|
||||
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_post_with_metadata_to_bucket():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
||||
|
||||
requests.post("https://foobar.s3.amazonaws.com/", {
|
||||
'key': 'the-key',
|
||||
'file': 'nothing',
|
||||
|
|
@ -198,6 +201,7 @@ def test_post_with_metadata_to_bucket():
|
|||
|
||||
bucket.get_key('the-key').get_metadata('test').should.equal('metadata')
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_bucket_method_not_implemented():
|
||||
requests.patch.when.called_with("https://foobar.s3.amazonaws.com/").should.throw(NotImplementedError)
|
||||
|
|
|
|||
|
|
@ -33,3 +33,18 @@ def test_s3_server_bucket_create():
|
|||
res = test_client.get('/bar', 'http://foobar.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal("test value")
|
||||
|
||||
|
||||
def test_s3_server_post_to_bucket():
|
||||
test_client = server.app.test_client()
|
||||
res = test_client.put('/', 'http://foobar.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
test_client.post('/', "https://foobar.localhost:5000/", data={
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
|
||||
res = test_client.get('/the-key', 'http://foobar.localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal("nothing")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue