Mercurial > piecrust2
comparison tests/test_uriutil.py @ 495:4284c673bb91
internal: Fix some edge-cases for splitting sub-URIs.
A given URI may or may not have a trailing slash, regardless of the
`trailing_slash` configuration setting. Add unit tests to check those cases.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 23 Jul 2015 22:11:59 -0700 |
parents | d4321317beae |
children | e85f29b28b84 |
comparison
equal
deleted
inserted
replaced
494:2537fe95d771 | 495:4284c673bb91 |
---|---|
28 | 28 |
29 @pytest.mark.parametrize('uri, expected, pretty_urls', [ | 29 @pytest.mark.parametrize('uri, expected, pretty_urls', [ |
30 ('/', ('/', 1), True), | 30 ('/', ('/', 1), True), |
31 ('/2', ('/', 2), True), | 31 ('/2', ('/', 2), True), |
32 ('/foo/bar', ('/foo/bar', 1), True), | 32 ('/foo/bar', ('/foo/bar', 1), True), |
33 ('/foo/bar/2', ('/foo/bar', 2), True), | 33 ('/foo/bar/', ('/foo/bar', 1), True), |
34 ('/foo/bar/2/', ('/foo/bar', 2), True), | |
34 ('/foo/bar.ext', ('/foo/bar.ext', 1), True), | 35 ('/foo/bar.ext', ('/foo/bar.ext', 1), True), |
35 ('/foo/bar.ext/2', ('/foo/bar.ext', 2), True), | 36 ('/foo/bar.ext/2', ('/foo/bar.ext', 2), True), |
36 ('/', ('/', 1), False), | 37 ('/', ('/', 1), False), |
37 ('/2.html', ('/', 2), False), | 38 ('/2.html', ('/', 2), False), |
38 ('/foo/bar.html', ('/foo/bar.html', 1), False), | 39 ('/foo/bar.html', ('/foo/bar.html', 1), False), |
51 | 52 |
52 | 53 |
53 @pytest.mark.parametrize('uri, expected, pretty_urls', [ | 54 @pytest.mark.parametrize('uri, expected, pretty_urls', [ |
54 ('/', ('/', 1), True), | 55 ('/', ('/', 1), True), |
55 ('/2/', ('/', 2), True), | 56 ('/2/', ('/', 2), True), |
57 ('/foo/bar', ('/foo/bar/', 1), True), | |
56 ('/foo/bar/', ('/foo/bar/', 1), True), | 58 ('/foo/bar/', ('/foo/bar/', 1), True), |
59 ('/foo/bar/2', ('/foo/bar/', 2), True), | |
57 ('/foo/bar/2/', ('/foo/bar/', 2), True), | 60 ('/foo/bar/2/', ('/foo/bar/', 2), True), |
58 ('/foo/bar.ext/', ('/foo/bar.ext/', 1), True), | 61 ('/foo/bar.ext/', ('/foo/bar.ext/', 1), True), |
59 ('/foo/bar.ext/2/', ('/foo/bar.ext/', 2), True), | 62 ('/foo/bar.ext/2/', ('/foo/bar.ext/', 2), True), |
60 ]) | 63 ]) |
61 def test_split_sub_uri_trailing_slash(uri, expected, pretty_urls): | 64 def test_split_sub_uri_trailing_slash(uri, expected, pretty_urls): |
71 | 74 |
72 @pytest.mark.parametrize('uri, expected, pretty_urls', [ | 75 @pytest.mark.parametrize('uri, expected, pretty_urls', [ |
73 ('/', ('/', 1), True), | 76 ('/', ('/', 1), True), |
74 ('/2', ('/', 2), True), | 77 ('/2', ('/', 2), True), |
75 ('/foo/bar', ('/foo/bar', 1), True), | 78 ('/foo/bar', ('/foo/bar', 1), True), |
79 ('/foo/bar/', ('/foo/bar', 1), True), | |
76 ('/foo/bar/2', ('/foo/bar', 2), True), | 80 ('/foo/bar/2', ('/foo/bar', 2), True), |
81 ('/foo/bar/2/', ('/foo/bar', 2), True), | |
77 ('/foo/bar.ext', ('/foo/bar.ext', 1), True), | 82 ('/foo/bar.ext', ('/foo/bar.ext', 1), True), |
78 ('/foo/bar.ext/2', ('/foo/bar.ext', 2), True), | 83 ('/foo/bar.ext/2', ('/foo/bar.ext', 2), True), |
79 ('/', ('/', 1), False), | 84 ('/', ('/', 1), False), |
80 ('/2.html', ('/', 2), False), | 85 ('/2.html', ('/', 2), False), |
81 ('/foo/bar.html', ('/foo/bar.html', 1), False), | 86 ('/foo/bar.html', ('/foo/bar.html', 1), False), |