Added tests and made current tests pass
This commit is contained in:
parent
d8e9301c54
commit
7de4399b93
2 changed files with 59 additions and 13 deletions
|
|
@ -101,7 +101,17 @@ 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')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
key = Key(bucket)
|
||||
key.key = 'the-key'
|
||||
key.set_metadata('md', 'Metadatastring')
|
||||
key.set_contents_from_string("Testval")
|
||||
|
||||
bucket.get_key('the-key').get_metadata('md').should.equal('Metadatastring')
|
||||
|
||||
@freeze_time("2012-01-01 12:00:00")
|
||||
@mock_s3
|
||||
|
|
@ -163,9 +173,34 @@ def test_get_all_buckets():
|
|||
buckets.should.have.length_of(2)
|
||||
|
||||
|
||||
@mock_s3
|
||||
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',
|
||||
'x-amz-meta-test': 'metadata'
|
||||
})
|
||||
|
||||
bucket.get_key('the-key').get_metadata('test').should.equal('metadata')
|
||||
|
||||
@mock_s3
|
||||
def test_bucket_method_not_implemented():
|
||||
requests.post.when.called_with("https://foobar.s3.amazonaws.com/").should.throw(NotImplementedError)
|
||||
requests.patch.when.called_with("https://foobar.s3.amazonaws.com/").should.throw(NotImplementedError)
|
||||
|
||||
|
||||
@mock_s3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue