test_paging.py 文件源码

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

项目:microcosm-flask 作者: globality-corp 项目源码 文件源码
def test_offset_limit_page_to_paginated_list():
    graph = create_object_graph(name="example", testing=True)

    ns = Namespace("foo")

    @graph.flask.route("/", methods=["GET"], endpoint="foo.search.v1")
    def search():
        pass

    with graph.flask.test_request_context():
        page = OffsetLimitPage(
            offset=10,
            limit=10,
            foo="bar",
        )
        result = [], 0
        paginated_list, headers = page.to_paginated_list(result, _ns=ns, _operation=Operation.Search)

        schema_cls = page.make_paginated_list_schema_class(ns, Schema())
        data = schema_cls().dump(paginated_list).data
        assert_that(
            data,
            is_(equal_to(dict(
                offset=10,
                limit=10,
                count=0,
                items=[],
                _links=dict(
                    self=dict(
                        href="http://localhost/?offset=10&limit=10&foo=bar",
                    ),
                    prev=dict(
                        href="http://localhost/?offset=0&limit=10&foo=bar",
                    ),
                ),
            ))))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号