test_model.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:dynamorm 作者: NerdWalletOSS 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号