Testing new version of decorator.
This commit is contained in:
parent
d3df810065
commit
fde721bed7
123 changed files with 2740 additions and 1114 deletions
|
|
@ -12,7 +12,7 @@ import requests
|
|||
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_s3bucket_path
|
||||
from moto import mock_s3, mock_s3_deprecated
|
||||
|
||||
|
||||
def create_connection(key=None, secret=None):
|
||||
|
|
@ -32,7 +32,7 @@ class MyModel(object):
|
|||
k.set_contents_from_string(self.value)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_my_model_save():
|
||||
# Create Bucket so that test can run
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
|
|
@ -45,14 +45,14 @@ def test_my_model_save():
|
|||
conn.get_bucket('mybucket').get_key('steve').get_contents_as_string().should.equal(b'is awesome')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_missing_key():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
bucket.get_key("the-key").should.equal(None)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_missing_key_urllib2():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
conn.create_bucket("foobar")
|
||||
|
|
@ -60,7 +60,7 @@ def test_missing_key_urllib2():
|
|||
urlopen.when.called_with("http://s3.amazonaws.com/foobar/the-key").should.throw(HTTPError)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_empty_key():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -71,7 +71,7 @@ def test_empty_key():
|
|||
bucket.get_key("the-key").get_contents_as_string().should.equal(b'')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_empty_key_set_on_existing_key():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -85,7 +85,7 @@ def test_empty_key_set_on_existing_key():
|
|||
bucket.get_key("the-key").get_contents_as_string().should.equal(b'')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_large_key_save():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -96,7 +96,7 @@ def test_large_key_save():
|
|||
bucket.get_key("the-key").get_contents_as_string().should.equal(b'foobar' * 100000)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_copy_key():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -110,7 +110,7 @@ def test_copy_key():
|
|||
bucket.get_key("new-key").get_contents_as_string().should.equal(b"some value")
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_set_metadata():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -123,7 +123,7 @@ def test_set_metadata():
|
|||
|
||||
|
||||
@freeze_time("2012-01-01 12:00:00")
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_last_modified():
|
||||
# See https://github.com/boto/boto/issues/466
|
||||
conn = create_connection()
|
||||
|
|
@ -138,19 +138,19 @@ def test_last_modified():
|
|||
bucket.get_key("the-key").last_modified.should.equal('Sun, 01 Jan 2012 12:00:00 GMT')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_missing_bucket():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
conn.get_bucket.when.called_with('mybucket').should.throw(S3ResponseError)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_bucket_with_dash():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
conn.get_bucket.when.called_with('mybucket-test').should.throw(S3ResponseError)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_bucket_deletion():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -172,7 +172,7 @@ def test_bucket_deletion():
|
|||
conn.delete_bucket.when.called_with("foobar").should.throw(S3ResponseError)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_get_all_buckets():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
conn.create_bucket("foobar")
|
||||
|
|
@ -182,7 +182,8 @@ def test_get_all_buckets():
|
|||
buckets.should.have.length_of(2)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3
|
||||
@mock_s3_deprecated
|
||||
def test_post_to_bucket():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -195,7 +196,8 @@ def test_post_to_bucket():
|
|||
bucket.get_key('the-key').get_contents_as_string().should.equal(b'nothing')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3
|
||||
@mock_s3_deprecated
|
||||
def test_post_with_metadata_to_bucket():
|
||||
conn = create_connection('the_key', 'the_secret')
|
||||
bucket = conn.create_bucket("foobar")
|
||||
|
|
@ -209,17 +211,17 @@ def test_post_with_metadata_to_bucket():
|
|||
bucket.get_key('the-key').get_metadata('test').should.equal('metadata')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3
|
||||
def test_bucket_method_not_implemented():
|
||||
requests.patch.when.called_with("https://s3.amazonaws.com/foobar").should.throw(NotImplementedError)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3
|
||||
def test_key_method_not_implemented():
|
||||
requests.post.when.called_with("https://s3.amazonaws.com/foobar/foo").should.throw(NotImplementedError)
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_bucket_name_with_dot():
|
||||
conn = create_connection()
|
||||
bucket = conn.create_bucket('firstname.lastname')
|
||||
|
|
@ -228,7 +230,7 @@ def test_bucket_name_with_dot():
|
|||
k.set_contents_from_string('somedata')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_key_with_special_characters():
|
||||
conn = create_connection()
|
||||
bucket = conn.create_bucket('test_bucket_name')
|
||||
|
|
@ -241,7 +243,7 @@ def test_key_with_special_characters():
|
|||
keys[0].name.should.equal("test_list_keys_2/*x+?^@~!y")
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_bucket_key_listing_order():
|
||||
conn = create_connection()
|
||||
bucket = conn.create_bucket('test_bucket')
|
||||
|
|
@ -283,7 +285,7 @@ def test_bucket_key_listing_order():
|
|||
keys.should.equal(['toplevel/x/'])
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_delete_keys():
|
||||
conn = create_connection()
|
||||
bucket = conn.create_bucket('foobar')
|
||||
|
|
@ -301,7 +303,7 @@ def test_delete_keys():
|
|||
keys[0].name.should.equal('file1')
|
||||
|
||||
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def test_delete_keys_with_invalid():
|
||||
conn = create_connection()
|
||||
bucket = conn.create_bucket('foobar')
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||
import boto
|
||||
from boto.s3.connection import OrdinaryCallingFormat
|
||||
|
||||
from moto import mock_s3bucket_path, mock_s3
|
||||
from moto import mock_s3_deprecated
|
||||
|
||||
|
||||
def create_connection(key=None, secret=None):
|
||||
|
|
@ -11,12 +11,12 @@ def create_connection(key=None, secret=None):
|
|||
|
||||
|
||||
def test_bucketpath_combo_serial():
|
||||
@mock_s3bucket_path
|
||||
@mock_s3_deprecated
|
||||
def make_bucket_path():
|
||||
conn = create_connection()
|
||||
conn.create_bucket('mybucketpath')
|
||||
|
||||
@mock_s3
|
||||
@mock_s3_deprecated
|
||||
def make_bucket():
|
||||
conn = boto.connect_s3('the_key', 'the_secret')
|
||||
conn.create_bucket('mybucket')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue