more s3 tests for posting
This commit is contained in:
parent
9f19662d1c
commit
3bc975188f
@ -11,12 +11,9 @@ class FakeKey(object):
|
||||
self.value = value
|
||||
self.last_modified = datetime.datetime.now()
|
||||
self._metadata = {}
|
||||
|
||||
|
||||
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
|
||||
@ -38,7 +35,7 @@ class FakeKey(object):
|
||||
# https://github.com/boto/boto/issues/466
|
||||
RFC1123 = '%a, %d %b %Y %H:%M:%S GMT'
|
||||
return self.last_modified.strftime(RFC1123)
|
||||
|
||||
|
||||
@property
|
||||
def metadata(self):
|
||||
return self._metadata
|
||||
|
@ -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…
Reference in New Issue
Block a user