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",
),
),
))))
评论列表
文章目录