use requires_boto_gte instead of removing the earlier versions

This commit is contained in:
Sorin 2014-01-07 10:56:51 +02:00
parent a31664ade7
commit b31c3ab8a5
4 changed files with 48 additions and 3 deletions

View File

@ -9,6 +9,8 @@ env:
- BOTO_VERSION=2.11.0 - BOTO_VERSION=2.11.0
- BOTO_VERSION=2.10.0 - BOTO_VERSION=2.10.0
- BOTO_VERSION=2.9.9 - BOTO_VERSION=2.9.9
- BOTO_VERSION=2.8
- BOTO_VERSION=2.7
install: install:
- pip install boto==$BOTO_VERSION - pip install boto==$BOTO_VERSION
- pip install https://github.com/gabrielfalcao/HTTPretty/tarball/8bbbdfc14326678b1aeba6a2d81af0d835a2cd6f - pip install https://github.com/gabrielfalcao/HTTPretty/tarball/8bbbdfc14326678b1aeba6a2d81af0d835a2cd6f

View File

@ -5,8 +5,10 @@ import boto.dynamodb2
from moto import mock_dynamodb2 from moto import mock_dynamodb2
from moto.dynamodb2 import dynamodb_backend2 from moto.dynamodb2 import dynamodb_backend2
from boto.exception import JSONResponseError from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_list_tables(): def test_list_tables():
name = 'TestTable' name = 'TestTable'
@ -22,6 +24,7 @@ def test_list_tables():
assert conn.list_tables()["TableNames"] == [name] assert conn.list_tables()["TableNames"] == [name]
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_list_tables_layer_1(): def test_list_tables_layer_1():
dynamodb_backend2.create_table("test_1",schema=[ dynamodb_backend2.create_table("test_1",schema=[
@ -44,6 +47,7 @@ def test_list_tables_layer_1():
res.should.equal(expected) res.should.equal(expected)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_describe_missing_table(): def test_describe_missing_table():
conn = boto.dynamodb2.connect_to_region( conn = boto.dynamodb2.connect_to_region(
@ -53,6 +57,7 @@ def test_describe_missing_table():
conn.describe_table.when.called_with('messages').should.throw(JSONResponseError) conn.describe_table.when.called_with('messages').should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_sts_handler(): def test_sts_handler():
res = requests.post("https://sts.amazonaws.com/", data={"GetSessionToken": ""}) res = requests.post("https://sts.amazonaws.com/", data={"GetSessionToken": ""})

View File

@ -10,6 +10,7 @@ from boto.dynamodb.exceptions import DynamoDBKeyNotFoundError
from boto.dynamodb2.exceptions import ValidationException from boto.dynamodb2.exceptions import ValidationException
from boto.dynamodb2.exceptions import ConditionalCheckFailedException from boto.dynamodb2.exceptions import ConditionalCheckFailedException
from boto.exception import JSONResponseError from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
def create_table(): def create_table():
table = Table.create('messages', schema=[ table = Table.create('messages', schema=[
@ -26,8 +27,10 @@ def iterate_results(res):
print i print i
@freeze_time("2012-01-14")
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
@freeze_time("2012-01-14")
def test_create_table(): def test_create_table():
table = create_table() table = create_table()
expected = { expected = {
@ -52,6 +55,7 @@ def test_create_table():
table.describe().should.equal(expected) table.describe().should.equal(expected)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_delete_table(): def test_delete_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection() conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -63,6 +67,7 @@ def test_delete_table():
conn.delete_table.when.called_with('messages').should.throw(JSONResponseError) conn.delete_table.when.called_with('messages').should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_update_table_throughput(): def test_update_table_throughput():
table = create_table() table = create_table()
@ -87,6 +92,7 @@ def test_update_table_throughput():
table.throughput["write"].should.equal(6) table.throughput["write"].should.equal(6)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_item_add_and_describe_and_update(): def test_item_add_and_describe_and_update():
table = create_table() table = create_table()
@ -129,6 +135,7 @@ def test_item_add_and_describe_and_update():
}) })
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_item_put_without_table(): def test_item_put_without_table():
@ -143,6 +150,7 @@ def test_item_put_without_table():
item.save.when.called_with().should.throw(JSONResponseError) item.save.when.called_with().should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_missing_item(): def test_get_missing_item():
@ -154,12 +162,14 @@ def test_get_missing_item():
).should.throw(ValidationException) ).should.throw(ValidationException)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_item_with_undeclared_table(): def test_get_item_with_undeclared_table():
table = Table('undeclared-table') table = Table('undeclared-table')
table.get_item.when.called_with(test_hash=3241526475).should.throw(JSONResponseError) table.get_item.when.called_with(test_hash=3241526475).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_item_without_range_key(): def test_get_item_without_range_key():
table = Table.create('messages', schema=[ table = Table.create('messages', schema=[
@ -176,6 +186,7 @@ def test_get_item_without_range_key():
table.get_item.when.called_with(test_hash=hash_key).should.throw(ValidationException) table.get_item.when.called_with(test_hash=hash_key).should.throw(ValidationException)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_delete_item(): def test_delete_item():
table = create_table() table = create_table()
@ -197,6 +208,7 @@ def test_delete_item():
item.delete.when.called_with().should.throw(ConditionalCheckFailedException) item.delete.when.called_with().should.throw(ConditionalCheckFailedException)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_delete_item_with_undeclared_table(): def test_delete_item_with_undeclared_table():
conn = boto.connect_dynamodb() conn = boto.connect_dynamodb()
@ -211,6 +223,7 @@ def test_delete_item_with_undeclared_table():
item.delete.when.called_with().should.throw(JSONResponseError) item.delete.when.called_with().should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_query(): def test_query():
@ -259,6 +272,7 @@ def test_query():
sum(1 for _ in results).should.equal(1) sum(1 for _ in results).should.equal(1)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_query_with_undeclared_table(): def test_query_with_undeclared_table():
table = Table('undeclared') table = Table('undeclared')
@ -270,6 +284,7 @@ def test_query_with_undeclared_table():
iterate_results.when.called_with(results).should.throw(JSONResponseError) iterate_results.when.called_with(results).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_scan(): def test_scan():
table = create_table() table = create_table()
@ -324,6 +339,7 @@ def test_scan():
sum(1 for _ in results).should.equal(1) sum(1 for _ in results).should.equal(1)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_scan_with_undeclared_table(): def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection() conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -340,6 +356,7 @@ def test_scan_with_undeclared_table():
).should.throw(JSONResponseError) ).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_write_batch(): def test_write_batch():
table = create_table() table = create_table()
@ -369,6 +386,7 @@ def test_write_batch():
table.count().should.equal(1) table.count().should.equal(1)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_batch_read(): def test_batch_read():
table = create_table() table = create_table()
@ -408,8 +426,9 @@ def test_batch_read():
count = len([x for x in results]) count = len([x for x in results])
count.should.equal(2) count.should.equal(2)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_key_fields(): def test_get_key_fields():
table = create_table() table = create_table()
kf = table.get_key_fields() kf = table.get_key_fields()
kf.should.equal(['forum_name','subject']) kf.should.equal(['forum_name','subject'])

View File

@ -7,6 +7,7 @@ from boto.dynamodb2.fields import HashKey
from boto.dynamodb2.fields import RangeKey from boto.dynamodb2.fields import RangeKey
from boto.dynamodb2.table import Table from boto.dynamodb2.table import Table
from boto.dynamodb2.table import Item from boto.dynamodb2.table import Item
from tests.helpers import requires_boto_gte
def create_table(): def create_table():
table = Table.create('messages', schema=[ table = Table.create('messages', schema=[
@ -18,8 +19,10 @@ def create_table():
return table return table
@freeze_time("2012-01-14")
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
@freeze_time("2012-01-14")
def test_create_table(): def test_create_table():
table = create_table() table = create_table()
expected = { expected = {
@ -47,6 +50,7 @@ def test_create_table():
conn.describe_table('messages').should.equal(expected) conn.describe_table('messages').should.equal(expected)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_delete_table(): def test_delete_table():
create_table() create_table()
@ -59,6 +63,7 @@ def test_delete_table():
conn.delete_table.when.called_with('messages').should.throw(JSONResponseError) conn.delete_table.when.called_with('messages').should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_update_table_throughput(): def test_update_table_throughput():
table = create_table() table = create_table()
@ -75,6 +80,7 @@ def test_update_table_throughput():
table.throughput["write"].should.equal(6) table.throughput["write"].should.equal(6)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_item_add_and_describe_and_update(): def test_item_add_and_describe_and_update():
table = create_table() table = create_table()
@ -108,6 +114,7 @@ def test_item_add_and_describe_and_update():
}) })
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_item_put_without_table(): def test_item_put_without_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection() conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -122,6 +129,7 @@ def test_item_put_without_table():
).should.throw(JSONResponseError) ).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_missing_item(): def test_get_missing_item():
table = create_table() table = create_table()
@ -129,6 +137,7 @@ def test_get_missing_item():
table.get_item.when.called_with(test_hash=3241526475).should.throw(JSONResponseError) table.get_item.when.called_with(test_hash=3241526475).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_item_with_undeclared_table(): def test_get_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection() conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -139,6 +148,7 @@ def test_get_item_with_undeclared_table():
).should.throw(JSONResponseError) ).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_delete_item(): def test_delete_item():
table = create_table() table = create_table()
@ -162,6 +172,7 @@ def test_delete_item():
item.delete.when.called_with().should.throw(JSONResponseError) item.delete.when.called_with().should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_delete_item_with_undeclared_table(): def test_delete_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection() conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -172,6 +183,7 @@ def test_delete_item_with_undeclared_table():
).should.throw(JSONResponseError) ).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_query(): def test_query():
table = create_table() table = create_table()
@ -191,6 +203,7 @@ def test_query():
sum(1 for _ in results).should.equal(1) sum(1 for _ in results).should.equal(1)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_query_with_undeclared_table(): def test_query_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection() conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -201,6 +214,7 @@ def test_query_with_undeclared_table():
).should.throw(JSONResponseError) ).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_scan(): def test_scan():
table = create_table() table = create_table()
@ -251,6 +265,7 @@ def test_scan():
sum(1 for _ in results).should.equal(1) sum(1 for _ in results).should.equal(1)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_scan_with_undeclared_table(): def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection() conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -268,6 +283,7 @@ def test_scan_with_undeclared_table():
).should.throw(JSONResponseError) ).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_write_batch(): def test_write_batch():
table = create_table() table = create_table()
@ -298,6 +314,7 @@ def test_write_batch():
table.count().should.equal(1) table.count().should.equal(1)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_batch_read(): def test_batch_read():
table = create_table() table = create_table()
@ -335,6 +352,7 @@ def test_batch_read():
count.should.equal(2) count.should.equal(2)
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_key_fields(): def test_get_key_fields():
table = create_table() table = create_table()
@ -342,6 +360,7 @@ def test_get_key_fields():
kf[0].should.equal('forum_name') kf[0].should.equal('forum_name')
@requires_boto_gte("2.9")
@mock_dynamodb2 @mock_dynamodb2
def test_get_special_item(): def test_get_special_item():
table = Table.create('messages', schema=[ table = Table.create('messages', schema=[