Mercurial > piecrust2
diff tests/test_data_paginator.py @ 352:498a917cd2d4
pagination: Make pagination use routes to generate proper URLs.
This fixes incorrect URLs when using custom sub-page suffixes, for instance.
Add tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 17 Apr 2015 16:09:30 -0700 |
parents | f130365568ff |
children | 4b1019bb2533 |
line wrap: on
line diff
--- a/tests/test_data_paginator.py Fri Apr 17 16:08:23 2015 -0700 +++ b/tests/test_data_paginator.py Fri Apr 17 16:09:30 2015 -0700 @@ -44,8 +44,17 @@ ('blog', 3, 14) ]) def test_paginator(uri, page_num, count): + def _mock_get_uri(index): + res = uri + if index > 1: + if res != '' and not res.endswith('/'): + res += '/' + res += '%d' % index + return res + source = MockSource(count) - p = Paginator(None, source, uri, page_num) + p = Paginator(None, source, page_num) + p._getPageUri = _mock_get_uri if count <= 5: # All posts fit on the page