def test_override_default_limit_from_request_header():
    graph = create_object_graph(name="example", testing=True)
    with graph.flask.test_request_context(headers={"X-Request-Limit": "2"}):
        page = OffsetLimitPage.from_dict(dict(foo="bar"))
        assert_that(page.offset, is_(equal_to(0)))
        assert_that(page.limit, is_(equal_to(2)))
        assert_that(page.kwargs, has_entry("foo", "bar"))
def test_override_default_limit_from_request_header():
    graph = create_object_graph(name="example", testing=True)
    with graph.flask.test_request_context(headers={"X-Request-Limit": "2"}):
        page = OffsetLimitPage.from_dict(dict(foo="bar"))
        assert_that(page.offset, is_(equal_to(0)))
        assert_that(page.limit, is_(equal_to(2)))
        assert_that(page.kwargs, has_entry("foo", "bar"))
def test_offset_limit_page_to_from_dict():
    page = OffsetLimitPage.from_dict(dict(offset=10, limit=10, foo="bar"))
    assert_that(page.offset, is_(equal_to(10)))
    assert_that(page.limit, is_(equal_to(10)))
    assert_that(page.to_dict(),
                is_(equal_to(dict(offset=10, limit=10, foo="bar"))))
def test_offset_limit_page_to_from_dict():
    page = OffsetLimitPage.from_dict(dict(offset=10, limit=10, foo="bar"))
    assert_that(page.offset, is_(equal_to(10)))
    assert_that(page.limit, is_(equal_to(10)))
    assert_that(page.to_dict(), is_(equal_to(dict(offset=10, limit=10, foo="bar"))))