comparison tests/test_baking_baker.py @ 6:f5ca5c5bed85

More Python 3 fixes, modularization, and new unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 16 Aug 2014 08:15:30 -0700
parents
children 617191dec18e
comparison
equal deleted inserted replaced
5:474c9882decf 6:f5ca5c5bed85
1 import pytest
2 from piecrust.baking.baker import PageBaker
3 from .mockutil import get_mock_app
4
5
6 @pytest.mark.parametrize('uri, page_num, pretty, expected', [
7 # Pretty URLs
8 ('', 1, True, 'index.html'),
9 ('', 2, True, '2/index.html'),
10 ('foo', 1, True, 'foo/index.html'),
11 ('foo', 2, True, 'foo/2/index.html'),
12 ('foo/bar', 1, True, 'foo/bar/index.html'),
13 ('foo/bar', 2, True, 'foo/bar/2/index.html'),
14 ('foo.ext', 1, True, 'foo.ext/index.html'),
15 ('foo.ext', 2, True, 'foo.ext/2/index.html'),
16 ('foo.bar.ext', 1, True, 'foo.bar.ext/index.html'),
17 ('foo.bar.ext', 2, True, 'foo.bar.ext/2/index.html'),
18 # Ugly URLs
19 ('', 1, False, 'index.html'),
20 ('', 2, False, '2.html'),
21 ('foo', 1, False, 'foo.html'),
22 ('foo', 2, False, 'foo/2.html'),
23 ('foo/bar', 1, False, 'foo/bar.html'),
24 ('foo/bar', 2, False, 'foo/bar/2.html'),
25 ('foo.ext', 1, False, 'foo.ext'),
26 ('foo.ext', 2, False, 'foo/2.ext'),
27 ('foo.bar.ext', 1, False, 'foo.bar.ext'),
28 ('foo.bar.ext', 2, False, 'foo.bar/2.ext')
29 ])
30 def test_get_output_path(uri, page_num, pretty, expected):
31 app = get_mock_app()
32 if pretty:
33 app.config.set('site/pretty_urls', True)
34 assert app.config.get('site/pretty_urls') == pretty
35
36 baker = PageBaker(app, '/destination')
37 sub_uri = baker.getOutputUri(uri, page_num)
38 path = baker.getOutputPath(sub_uri)
39 expected = '/destination/' + expected
40 assert expected == path
41