comparison tests/test_uriutil.py @ 33:62c7a97c8340

Get the un-paginated URL of a page early and pass that around.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 19 Aug 2014 15:36:28 -0700
parents 474c9882decf
children eb958151c8dc
comparison
equal deleted inserted replaced
32:43091c9837bf 33:62c7a97c8340
1 import mock
1 import pytest 2 import pytest
2 from piecrust.uriutil import UriInfo, parse_uri 3 from piecrust.uriutil import UriInfo, parse_uri, get_first_sub_uri
3 4
4 5
5 @pytest.mark.parametrize('routes, uri, expected', [ 6 @pytest.mark.parametrize('routes, uri, expected', [
6 ({}, '/foo', None), 7 ({}, '/foo', None),
7 ( 8 (
22 args['taxonomy'] = None 23 args['taxonomy'] = None
23 24
24 actual = parse_uri(routes, uri) 25 actual = parse_uri(routes, uri)
25 assert actual == expected 26 assert actual == expected
26 27
28
29 @pytest.mark.parametrize('uri, expected, pretty_urls', [
30 ('foo/bar', 'foo/bar', True),
31 ('foo/bar/2', 'foo/bar', True),
32 ('foo/bar.ext', 'foo/bar.ext', True),
33 ('foo/bar.ext/2', 'foo/bar.ext', True),
34 ('foo/bar.html', 'foo/bar.html', False),
35 ('foo/bar/2.html', 'foo/bar.html', False),
36 ('foo/bar.ext', 'foo/bar.ext', False),
37 ('foo/bar/2.ext', 'foo/bar.ext', False)
38 ])
39 def test_get_first_sub_uri(uri, expected, pretty_urls):
40 app = mock.MagicMock()
41 app.config = {
42 'site/pretty_urls': pretty_urls,
43 '__cache/pagination_suffix_re': '/(\\d+)$'}
44 actual = get_first_sub_uri(app, uri)
45 assert actual == expected
46