2013-02-19 13:26:05 +00:00
|
|
|
import boto
|
2013-03-13 13:06:45 +00:00
|
|
|
import sure # flake8: noqa
|
2013-02-20 01:39:04 +00:00
|
|
|
from freezegun import freeze_time
|
|
|
|
|
2013-02-19 13:26:05 +00:00
|
|
|
from moto import mock_dynamodb
|
|
|
|
from moto.dynamodb import dynamodb_backend
|
|
|
|
|
2013-03-13 14:11:13 +00:00
|
|
|
from boto.dynamodb import condition
|
2013-03-10 19:46:27 +00:00
|
|
|
from boto.exception import DynamoDBResponseError
|
|
|
|
|
2013-02-19 13:26:05 +00:00
|
|
|
|
|
|
|
@mock_dynamodb
|
2013-02-20 01:01:31 +00:00
|
|
|
def test_list_tables():
|
2013-02-20 01:39:04 +00:00
|
|
|
name = 'TestTable'
|
2013-03-15 02:52:32 +00:00
|
|
|
dynamodb_backend.create_table(name, hash_key_attr="name", hash_key_type="S")
|
2013-02-19 13:26:05 +00:00
|
|
|
conn = boto.connect_dynamodb('the_key', 'the_secret')
|
|
|
|
assert conn.list_tables() == ['TestTable']
|
2013-02-20 01:39:04 +00:00
|
|
|
|
|
|
|
|
2013-03-11 01:16:44 +00:00
|
|
|
@mock_dynamodb
|
|
|
|
def test_list_tables_layer_1():
|
2013-03-15 02:52:32 +00:00
|
|
|
dynamodb_backend.create_table("test_1", hash_key_attr="name", hash_key_type="S")
|
|
|
|
dynamodb_backend.create_table("test_2", hash_key_attr="name", hash_key_type="S")
|
2013-03-11 01:16:44 +00:00
|
|
|
conn = boto.connect_dynamodb('the_key', 'the_secret')
|
|
|
|
res = conn.layer1.list_tables(limit=1)
|
|
|
|
expected = {"TableNames": ["test_1"], "LastEvaluatedTableName": "test_1"}
|
|
|
|
res.should.equal(expected)
|
|
|
|
|
|
|
|
res = conn.layer1.list_tables(limit=1, start_table="test_1")
|
|
|
|
expected = {"TableNames": ["test_2"]}
|
|
|
|
res.should.equal(expected)
|
|
|
|
|
|
|
|
|
2013-03-10 19:46:27 +00:00
|
|
|
@mock_dynamodb
|
|
|
|
def test_describe_missing_table():
|
|
|
|
conn = boto.connect_dynamodb('the_key', 'the_secret')
|
|
|
|
conn.describe_table.when.called_with('messages').should.throw(DynamoDBResponseError)
|