Testing new version of decorator.

This commit is contained in:
Steve Pulec 2017-02-15 22:35:45 -05:00
commit fde721bed7
123 changed files with 2740 additions and 1114 deletions

View file

@ -4,7 +4,7 @@ import six
import boto
import sure # noqa
import requests
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from moto.dynamodb2 import dynamodb_backend2
from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
@ -16,7 +16,7 @@ except ImportError:
print("This boto version is not supported")
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_list_tables():
name = 'TestTable'
#{'schema': }
@ -32,7 +32,7 @@ def test_list_tables():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_list_tables_layer_1():
dynamodb_backend2.create_table("test_1",schema=[
{u'KeyType': u'HASH', u'AttributeName': u'name'}
@ -55,7 +55,7 @@ def test_list_tables_layer_1():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_describe_missing_table():
conn = boto.dynamodb2.connect_to_region(
'us-west-2',

View file

@ -7,7 +7,7 @@ import boto3
from boto3.dynamodb.conditions import Key
import sure # noqa
from freezegun import freeze_time
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
try:
@ -61,7 +61,7 @@ def iterate_results(res):
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table():
table = create_table()
@ -90,7 +90,7 @@ def test_create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table_with_local_index():
table = create_table_with_local_indexes()
@ -132,7 +132,7 @@ def test_create_table_with_local_index():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
table = create_table()
@ -144,7 +144,7 @@ def test_delete_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_table_throughput():
table = create_table()
table.throughput["read"].should.equal(10)
@ -169,7 +169,7 @@ def test_update_table_throughput():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_add_and_describe_and_update():
table = create_table()
ok = table.put_item(data={
@ -212,7 +212,7 @@ def test_item_add_and_describe_and_update():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_partial_save():
table = create_table()
@ -242,7 +242,7 @@ def test_item_partial_save():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_put_without_table():
table = Table('undeclared-table')
item_data = {
@ -256,7 +256,7 @@ def test_item_put_without_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_missing_item():
table = create_table()
@ -267,14 +267,14 @@ def test_get_missing_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_with_undeclared_table():
table = Table('undeclared-table')
table.get_item.when.called_with(test_hash=3241526475).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_without_range_key():
table = Table.create('messages', schema=[
HashKey('test_hash'),
@ -291,7 +291,7 @@ def test_get_item_without_range_key():
@requires_boto_gte("2.30.0")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item():
table = create_table()
item_data = {
@ -313,7 +313,7 @@ def test_delete_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item_with_undeclared_table():
table = Table("undeclared-table")
item_data = {
@ -327,7 +327,7 @@ def test_delete_item_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query():
table = create_table()
@ -384,7 +384,7 @@ def test_query():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_undeclared_table():
table = Table('undeclared')
results = table.query(
@ -396,7 +396,7 @@ def test_query_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan():
table = create_table()
item_data = {
@ -451,7 +451,7 @@ def test_scan():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
conn.scan.when.called_with(
@ -468,7 +468,7 @@ def test_scan_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_write_batch():
table = create_table()
with table.batch_write() as batch:
@ -498,7 +498,7 @@ def test_write_batch():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_batch_read():
table = create_table()
item_data = {
@ -542,14 +542,14 @@ def test_batch_read():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_key_fields():
table = create_table()
kf = table.get_key_fields()
kf.should.equal(['forum_name', 'subject'])
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_create_with_global_indexes():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -594,7 +594,7 @@ def test_create_with_global_indexes():
])
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_global_indexes():
table = Table.create('messages', schema=[
HashKey('subject'),
@ -638,7 +638,7 @@ def test_query_with_global_indexes():
list(results).should.have.length_of(0)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_local_indexes():
table = create_table_with_local_indexes()
item_data = {
@ -658,7 +658,7 @@ def test_query_with_local_indexes():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_eq():
table = create_table_with_local_indexes()
item_data = [
@ -691,7 +691,7 @@ def test_query_filter_eq():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_lt():
table = create_table_with_local_indexes()
item_data = [
@ -726,7 +726,7 @@ def test_query_filter_lt():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_gt():
table = create_table_with_local_indexes()
item_data = [
@ -760,7 +760,7 @@ def test_query_filter_gt():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_lte():
table = create_table_with_local_indexes()
item_data = [
@ -794,7 +794,7 @@ def test_query_filter_lte():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_gte():
table = create_table_with_local_indexes()
item_data = [
@ -827,7 +827,7 @@ def test_query_filter_gte():
list(results).should.have.length_of(2)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_reverse_query():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -851,7 +851,7 @@ def test_reverse_query():
[r['created_at'] for r in results].should.equal(expected)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_lookup():
from decimal import Decimal
table = Table.create('messages', schema=[
@ -871,7 +871,7 @@ def test_lookup():
message.get('test_range').should.equal(Decimal(range_key))
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_failed_overwrite():
table = Table.create('messages', schema=[
HashKey('id'),
@ -900,7 +900,7 @@ def test_failed_overwrite():
dict(returned_item).should.equal(data4)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_conflicting_writes():
table = Table.create('messages', schema=[
HashKey('id'),

View file

@ -6,7 +6,7 @@ from boto3.dynamodb.conditions import Key
import sure # noqa
from freezegun import freeze_time
from boto.exception import JSONResponseError
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from tests.helpers import requires_boto_gte
import botocore
try:
@ -29,7 +29,7 @@ def create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table():
create_table()
@ -62,7 +62,7 @@ def test_create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_table():
create_table()
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -75,7 +75,7 @@ def test_delete_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_table_throughput():
table = create_table()
table.throughput["read"].should.equal(10)
@ -91,7 +91,7 @@ def test_update_table_throughput():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_add_and_describe_and_update():
table = create_table()
@ -125,7 +125,7 @@ def test_item_add_and_describe_and_update():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_partial_save():
table = create_table()
@ -152,7 +152,7 @@ def test_item_partial_save():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_put_without_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -167,7 +167,7 @@ def test_item_put_without_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -178,7 +178,7 @@ def test_get_item_with_undeclared_table():
@requires_boto_gte("2.30.0")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item():
table = create_table()
@ -202,7 +202,7 @@ def test_delete_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -213,7 +213,7 @@ def test_delete_item_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query():
table = create_table()
@ -233,7 +233,7 @@ def test_query():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -244,7 +244,7 @@ def test_query_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan():
table = create_table()
@ -295,7 +295,7 @@ def test_scan():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -313,7 +313,7 @@ def test_scan_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_write_batch():
table = create_table()
@ -344,7 +344,7 @@ def test_write_batch():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_batch_read():
table = create_table()
@ -385,7 +385,7 @@ def test_batch_read():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_key_fields():
table = create_table()
kf = table.get_key_fields()
@ -393,14 +393,14 @@ def test_get_key_fields():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_missing_item():
table = create_table()
table.get_item.when.called_with(forum_name='missing').should.throw(ItemNotFound)
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_special_item():
table = Table.create('messages', schema=[
HashKey('date-joined')
@ -418,7 +418,7 @@ def test_get_special_item():
dict(returned_item).should.equal(data)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_item_remove():
conn = boto.dynamodb2.connect_to_region("us-west-2")
table = Table.create('messages', schema=[
@ -444,7 +444,7 @@ def test_update_item_remove():
})
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_item_set():
conn = boto.dynamodb2.connect_to_region("us-west-2")
table = Table.create('messages', schema=[
@ -471,7 +471,7 @@ def test_update_item_set():
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_failed_overwrite():
table = Table.create('messages', schema=[
HashKey('id'),
@ -499,7 +499,7 @@ def test_failed_overwrite():
dict(returned_item).should.equal(data4)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_conflicting_writes():
table = Table.create('messages', schema=[
HashKey('id'),