Mercurial > piecrust2
diff tests/test_data_paginator.py @ 369:4b1019bb2533
serve: Giant refactor to change how we handle data when serving pages.
* We need a distinction between source metadata and route metadata. In most
cases they're the same, but in cases like taxonomy pages, route metadata
contains more things that can't be in source metadata if we want to re-use
cached pages.
* Create a new `QualifiedPage` type which is a page with a specific route
and route metadata. Pass this around in many places.
* Instead of passing an URL around, use the route in the `QualifiedPage` to
generate URLs. This is better since it removes the guess-work from trying
to generate URLs for sub-pages.
* Deep-copy app and page configurations before passing them around to things
that could modify them, like data builders and such.
* Exclude taxonomy pages from iterator data providers.
* Properly nest iterator data providers for when the theme and user page
sources are merged inside `site.pages`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 03 May 2015 18:47:10 -0700 |
parents | 498a917cd2d4 |
children | 72f17534d58e |
line wrap: on
line diff
--- a/tests/test_data_paginator.py Sun May 03 18:43:28 2015 -0700 +++ b/tests/test_data_paginator.py Sun May 03 18:47:10 2015 -0700 @@ -1,4 +1,5 @@ import math +import mock import pytest from piecrust.data.paginator import Paginator from piecrust.sources.interfaces import IPaginationSource @@ -44,17 +45,17 @@ ('blog', 3, 14) ]) def test_paginator(uri, page_num, count): - def _mock_get_uri(index): + def _get_mock_uri(sub_num): res = uri - if index > 1: + if sub_num > 1: if res != '' and not res.endswith('/'): res += '/' - res += '%d' % index + res += '%d' % sub_num return res source = MockSource(count) - p = Paginator(None, source, page_num) - p._getPageUri = _mock_get_uri + p = Paginator(None, source, page_num=page_num) + p._getPageUri = _get_mock_uri if count <= 5: # All posts fit on the page