Mercurial > piecrust2
comparison tests/test_uriutil.py @ 316:eb958151c8dc
tests: Bad me, the tests were broken. Now they're fixed.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 28 Mar 2015 12:41:02 -0700 |
parents | 62c7a97c8340 |
children | 422052d2e978 |
comparison
equal
deleted
inserted
replaced
315:d1490028e211 | 316:eb958151c8dc |
---|---|
1 import mock | 1 import mock |
2 import pytest | 2 import pytest |
3 from piecrust.uriutil import UriInfo, parse_uri, get_first_sub_uri | 3 from piecrust.uriutil import UriInfo, parse_uri, split_sub_uri |
4 | 4 |
5 | 5 |
6 @pytest.mark.parametrize('routes, uri, expected', [ | 6 @pytest.mark.parametrize('routes, uri, expected', [ |
7 ({}, '/foo', None), | 7 ({}, '/foo', None), |
8 ( | 8 ( |
25 actual = parse_uri(routes, uri) | 25 actual = parse_uri(routes, uri) |
26 assert actual == expected | 26 assert actual == expected |
27 | 27 |
28 | 28 |
29 @pytest.mark.parametrize('uri, expected, pretty_urls', [ | 29 @pytest.mark.parametrize('uri, expected, pretty_urls', [ |
30 ('foo/bar', 'foo/bar', True), | 30 ('foo/bar', ('foo/bar', 1), True), |
31 ('foo/bar/2', 'foo/bar', True), | 31 ('foo/bar/2', ('foo/bar', 2), True), |
32 ('foo/bar.ext', 'foo/bar.ext', True), | 32 ('foo/bar.ext', ('foo/bar.ext', 1), True), |
33 ('foo/bar.ext/2', 'foo/bar.ext', True), | 33 ('foo/bar.ext/2', ('foo/bar.ext', 2), True), |
34 ('foo/bar.html', 'foo/bar.html', False), | 34 ('foo/bar.html', ('foo/bar.html', 1), False), |
35 ('foo/bar/2.html', 'foo/bar.html', False), | 35 ('foo/bar/2.html', ('foo/bar.html', 2), False), |
36 ('foo/bar.ext', 'foo/bar.ext', False), | 36 ('foo/bar.ext', ('foo/bar.ext', 1), False), |
37 ('foo/bar/2.ext', 'foo/bar.ext', False) | 37 ('foo/bar/2.ext', ('foo/bar.ext', 2), False) |
38 ]) | 38 ]) |
39 def test_get_first_sub_uri(uri, expected, pretty_urls): | 39 def test_split_sub_uri(uri, expected, pretty_urls): |
40 app = mock.MagicMock() | 40 app = mock.MagicMock() |
41 app.config = { | 41 app.config = { |
42 'site/pretty_urls': pretty_urls, | 42 'site/pretty_urls': pretty_urls, |
43 '__cache/pagination_suffix_re': '/(\\d+)$'} | 43 '__cache/pagination_suffix_re': '/(?P<num>\\d+)$'} |
44 actual = get_first_sub_uri(app, uri) | 44 actual = split_sub_uri(app, uri) |
45 assert actual == expected | 45 assert actual == expected |
46 | 46 |