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",
                            ),
                        ),
                    ))))
def test_default_values_for_offset_limit_page():
    page = OffsetLimitPage(foo="bar")
    assert_that(page.offset, is_(equal_to(0)))
    assert_that(page.limit, is_(equal_to(20)))
    assert_that(page.kwargs, has_entry("foo", "bar"))