示例#1
0
 def test_table_eq(self):
     """Tables should be equal"""
     field = DynamoKey("foo")
     a, b = Table("a", field), Table("a", field)
     self.assertEqual(a, b)
     self.assertEqual(hash(a), hash(b))
     self.assertFalse(a != b)
示例#2
0
 def test_create_hash_table(self):
     """ Create a table with just a hash key """
     hash_key = DynamoKey('id', data_type=STRING)
     table = Table('foobar', hash_key)
     self.dynamo.create_table('foobar', hash_key=hash_key)
     desc = self.dynamo.describe_table('foobar')
     self.assertEqual(desc, table)
示例#3
0
 def test_create_hash_range_table(self):
     """ Create a table with a hash and range key """
     hash_key = DynamoKey('id', data_type=STRING)
     range_key = DynamoKey('num', data_type=NUMBER)
     table = Table('foobar', hash_key, range_key)
     self.dynamo.create_table('foobar', hash_key, range_key)
     desc = self.dynamo.describe_table('foobar')
     self.assertEqual(desc, table)
示例#4
0
 def test_create_table_throughput(self):
     """Create a table and set throughput"""
     hash_key = DynamoKey("id", data_type=STRING)
     throughput = Throughput(8, 2)
     table = Table("foobar", hash_key, throughput=throughput)
     self.dynamo.create_table("foobar", hash_key=hash_key, throughput=throughput)
     desc = self.dynamo.describe_table("foobar")
     self.assertEqual(desc, table)
示例#5
0
 def test_create_global_keys_index(self):
     """ Create a table with a global KeysOnly index """
     hash_key = DynamoKey('id', data_type=STRING)
     index_field = DynamoKey('name')
     index = GlobalIndex.keys('name-index', index_field)
     table = Table('foobar', hash_key, global_indexes=[index])
     self.dynamo.create_table('foobar', hash_key, global_indexes=[index])
     desc = self.dynamo.describe_table('foobar')
     self.assertEqual(desc, table)
示例#6
0
 def test_create_global_index(self):
     """Create a table with a global index"""
     hash_key = DynamoKey("id", data_type=STRING)
     index_field = DynamoKey("name")
     index = GlobalIndex.all("name-index", index_field)
     table = Table("foobar", hash_key, global_indexes=[index])
     self.dynamo.create_table("foobar", hash_key, global_indexes=[index])
     desc = self.dynamo.describe_table("foobar")
     self.assertEqual(desc, table)
示例#7
0
 def test_create_global_hash_range_index(self):
     """ Create a global index with a hash and range key """
     hash_key = DynamoKey('id', data_type=STRING)
     index_hash = DynamoKey('foo')
     index_range = DynamoKey('bar')
     index = GlobalIndex.all('foo-index', index_hash, index_range)
     table = Table('foobar', hash_key, global_indexes=[index])
     self.dynamo.create_table('foobar', hash_key, global_indexes=[index])
     desc = self.dynamo.describe_table('foobar')
     self.assertEqual(desc, table)
示例#8
0
 def test_create_local_includes_index(self):
     """Create a table with a local Includes index"""
     hash_key = DynamoKey("id", data_type=STRING)
     range_key = DynamoKey("num", data_type=NUMBER)
     index_field = DynamoKey("name")
     index = LocalIndex.include("name-index", index_field, includes=["foo", "bar"])
     table = Table("foobar", hash_key, range_key, [index])
     self.dynamo.create_table("foobar", hash_key, range_key, indexes=[index])
     desc = self.dynamo.describe_table("foobar")
     self.assertEqual(desc, table)
示例#9
0
 def test_create_global_index_throughput(self):
     """Create a table and set throughput on global index"""
     hash_key = DynamoKey("id", data_type=STRING)
     throughput = Throughput(8, 2)
     index_field = DynamoKey("name")
     index = GlobalIndex.all("name-index", index_field, throughput=throughput)
     table = Table("foobar", hash_key, global_indexes=[index], throughput=throughput)
     self.dynamo.create_table(
         "foobar", hash_key=hash_key, global_indexes=[index], throughput=throughput
     )
     desc = self.dynamo.describe_table("foobar")
     self.assertEqual(desc, table)
示例#10
0
 def test_create_local_index(self):
     """ Create a table with a local index """
     hash_key = DynamoKey('id', data_type=STRING)
     range_key = DynamoKey('num', data_type=NUMBER)
     index_field = DynamoKey('name')
     index = LocalIndex.all('name-index', index_field)
     table = Table('foobar', hash_key, range_key, [index])
     self.dynamo.create_table('foobar',
                              hash_key,
                              range_key,
                              indexes=[index])
     desc = self.dynamo.describe_table('foobar')
     self.assertEqual(desc, table)