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, })
def test_create(self): """ CREATE statement should make a table """ self.query(""" CREATE TABLE foobar (owner STRING HASH KEY, id BINARY RANGE KEY, ts NUMBER INDEX('ts-index')) """) desc = self.engine.describe('foobar') self.assertEquals(desc.hash_key, TableField('owner', 'STRING', 'HASH')) self.assertEquals(desc.range_key, TableField('id', 'BINARY', 'RANGE')) self.assertEqual( desc.attrs, { 'owner': TableField('owner', 'STRING', 'HASH'), 'id': TableField('id', 'BINARY', 'RANGE'), 'ts': IndexField('ts', 'NUMBER', 'ALL', 'ts-index'), })
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(self): """ CREATE statement should make a table """ self.query(""" CREATE TABLE foobar (owner STRING HASH KEY, id BINARY RANGE KEY, ts NUMBER INDEX('ts-index')) """) desc = self.engine.describe("foobar") self.assertEqual(desc.hash_key, TableField("owner", "STRING", "HASH")) self.assertEqual(desc.range_key, TableField("id", "BINARY", "RANGE")) self.assertEqual( desc.attrs, { "owner": TableField("owner", "STRING", "HASH"), "id": TableField("id", "BINARY", "RANGE"), "ts": IndexField("ts", "NUMBER", "ALL", "ts-index"), }, )
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})