Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
351:1f22d4b10fef | 352:498a917cd2d4 |
---|---|
42 ('blog', 2, 8), | 42 ('blog', 2, 8), |
43 ('blog', 2, 14), | 43 ('blog', 2, 14), |
44 ('blog', 3, 14) | 44 ('blog', 3, 14) |
45 ]) | 45 ]) |
46 def test_paginator(uri, page_num, count): | 46 def test_paginator(uri, page_num, count): |
47 def _mock_get_uri(index): | |
48 res = uri | |
49 if index > 1: | |
50 if res != '' and not res.endswith('/'): | |
51 res += '/' | |
52 res += '%d' % index | |
53 return res | |
54 | |
47 source = MockSource(count) | 55 source = MockSource(count) |
48 p = Paginator(None, source, uri, page_num) | 56 p = Paginator(None, source, page_num) |
57 p._getPageUri = _mock_get_uri | |
49 | 58 |
50 if count <= 5: | 59 if count <= 5: |
51 # All posts fit on the page | 60 # All posts fit on the page |
52 assert p.prev_page_number is None | 61 assert p.prev_page_number is None |
53 assert p.prev_page is None | 62 assert p.prev_page is None |