add more s3 functions
This commit is contained in:
parent
e20ae8e91c
commit
28a46a5a3a
3 changed files with 89 additions and 13 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import boto
|
||||
from boto.exception import S3ResponseError
|
||||
from boto.s3.key import Key
|
||||
|
||||
import sure
|
||||
|
||||
from moto import mock_s3
|
||||
|
||||
|
||||
|
|
@ -28,3 +31,25 @@ def test_my_model_save():
|
|||
model_instance.save()
|
||||
|
||||
assert conn.get_bucket('mybucket').get_key('steve').get_contents_as_string() == 'is awesome'
|
||||
|
||||
@mock_s3
|
||||
def test_missing_bucket():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
conn.get_bucket.when.called_with('mybucket').should.throw(S3ResponseError)
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_bucket_deletion():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
||||
key = Key(bucket)
|
||||
key.key = "the-key"
|
||||
key.set_contents_from_string("some value")
|
||||
|
||||
conn.delete_bucket.when.called_with("foobar").should.throw(S3ResponseError)
|
||||
|
||||
bucket.delete_key("the-key")
|
||||
conn.delete_bucket("foobar")
|
||||
|
||||
conn.get_bucket.when.called_with("foobar").should.throw(S3ResponseError)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue