def test_index_setup():
"""Ensure our index objects are setup & transformed correctly by our meta class"""
class Model(DynaModel):
class Table:
name = 'table'
hash_key = 'foo'
range_key = 'bar'
read = 1
write = 1
class Index(GlobalIndex):
name = 'test-idx'
hash_key = 'foo'
range_key = 'bar'
projection = ProjectAll()
class Schema:
foo = String(required=True)
bar = String(required=True)
model = Model(foo='hi', bar='there')
assert 'test-idx' in model.Table.indexes
assert model.Index.index is model.Table.indexes['test-idx']
assert model.Index.index.table is model.Table
assert model.Index.index.schema is model.Schema
# this gets automatically set during initialization, since read is an optional parameter
assert model.Index.index.read is None
评论列表
文章目录