more s3 tests for posting

This commit is contained in:
Steve Pulec 2013-05-17 19:41:39 -04:00
parent 9f19662d1c
commit 3bc975188f
3 changed files with 25 additions and 9 deletions

View File

@ -15,9 +15,6 @@ class FakeKey(object):
def set_metadata(self, key, metadata):
self._metadata[key] = metadata
def get_metadata(self, key):
return self._metadata[key]
def append_to_value(self, value):
self.value += value
self.last_modified = datetime.datetime.now()

View File

@ -102,6 +102,7 @@ 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():
@ -185,6 +187,7 @@ def test_post_to_bucket():
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')
@ -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)

View File

@ -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")