def test_create_global_keys_index(self): """ Can create a global keys-only index """ self.query("CREATE TABLE foobar (id STRING HASH KEY, foo NUMBER) " "GLOBAL KEYS INDEX ('myindex', foo, THROUGHPUT (1, 2))") desc = self.engine.describe("foobar") hash_key = TableField("foo", "NUMBER", "HASH") gindex = GlobalIndex("myindex", "KEYS", "ACTIVE", hash_key, None, 1, 2, 0) self.assertEqual(desc.global_indexes, {"myindex": gindex})
def test_create_global_keys_index(self): """ Can create a global keys-only index """ self.query("CREATE TABLE foobar (id STRING HASH KEY, foo NUMBER) " "GLOBAL KEYS INDEX ('myindex', foo, THROUGHPUT (1, 2))") desc = self.engine.describe('foobar') hash_key = TableField('foo', 'NUMBER', 'HASH') gindex = GlobalIndex('myindex', 'KEYS', 'ACTIVE', hash_key, None, 1, 2, 0) self.assertEquals(desc.global_indexes, { 'myindex': gindex, })
def test_create_global_include_index(self): """ Can create a global include-only index """ self.query( "CREATE TABLE foobar (id STRING HASH KEY, foo NUMBER) " "GLOBAL INCLUDE INDEX ('myindex', foo, ['bar', 'baz'], THROUGHPUT (1, 2))" ) desc = self.engine.describe("foobar") hash_key = TableField("foo", "NUMBER", "HASH") gindex = GlobalIndex("myindex", "INCLUDE", "ACTIVE", hash_key, None, 1, 2, 0, ["bar", "baz"]) self.assertEqual(desc.global_indexes, {"myindex": gindex})
def test_create_global_indexes(self): """ Can create with global indexes """ self.query( "CREATE TABLE foobar (id STRING HASH KEY, foo NUMBER RANGE KEY) " "GLOBAL INDEX ('myindex', foo, id, THROUGHPUT (1, 2))") desc = self.engine.describe("foobar") hash_key = TableField("foo", "NUMBER", "HASH") range_key = TableField("id", "STRING", "RANGE") gindex = GlobalIndex("myindex", "ALL", "ACTIVE", hash_key, range_key, 1, 2, 0) self.assertEqual(desc.global_indexes, {"myindex": gindex})
def test_create_global_indexes(self): """ Can create with global indexes """ self.query( "CREATE TABLE foobar (id STRING HASH KEY, foo NUMBER RANGE KEY) " "GLOBAL INDEX ('myindex', foo, id, THROUGHPUT (1, 2))") desc = self.engine.describe('foobar') hash_key = TableField('foo', 'NUMBER', 'HASH') range_key = TableField('id', 'STRING', 'RANGE') gindex = GlobalIndex('myindex', 'ALL', 'ACTIVE', hash_key, range_key, 1, 2, 0) self.assertEquals(desc.global_indexes, { 'myindex': gindex, })
def test_create_global_index_types(self): """ Global indexes can specify the attribute types """ self.query( "CREATE TABLE foobar (id STRING HASH KEY, foo NUMBER RANGE KEY) " "GLOBAL INDEX ('myindex', foo number, baz string, THROUGHPUT (1, 2))" ) desc = self.engine.describe('foobar') hash_key = TableField('foo', 'NUMBER', 'HASH') range_key = TableField('baz', 'STRING', 'RANGE') gindex = GlobalIndex('myindex', 'ALL', 'ACTIVE', hash_key, range_key, 1, 2, 0) self.assertEquals(desc.global_indexes, { 'myindex': gindex, })