def test_offset_limit_page_from_query_string(): graph = create_object_graph(name="example", testing=True) with graph.flask.test_request_context(query_string="offset=1&foo=bar"): page = OffsetLimitPage.from_query_string(OffsetLimitPageSchema()) assert_that(page.offset, is_(equal_to(1))) assert_that(page.limit, is_(equal_to(20))) # schema filters out extra arguments assert_that(page.to_dict(), is_not(has_entry("foo", "bar")))
def discover(): # accept pagination limit from request page = OffsetLimitPage.from_query_string(page_schema) page.offset = 0 response_data = dict(_links=Links({ "self": Link.for_(Operation.Discover, ns, qs=page.to_items()), "search": [ link for link in iter_links( self.find_matching_endpoints(ns), page) ], }).to_dict()) return make_response(response_data)
def test_offset_limit_page_from_query_string(): graph = create_object_graph(name="example", testing=True) with graph.flask.test_request_context(query_string="offset=1"): page = OffsetLimitPage.from_query_string(OffsetLimitPageSchema()) assert_that(page.offset, is_(equal_to(1))) assert_that(page.limit, is_(equal_to(20)))