comparison tests/test_pagebaker.py @ 3:f485ba500df3

Gigantic change to basically make PieCrust 2 vaguely functional. - Serving works, with debug window. - Baking works, multi-threading, with dependency handling. - Various things not implemented yet.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 10 Aug 2014 23:43:16 -0700
parents
children
comparison
equal deleted inserted replaced
2:40fa08b261b9 3:f485ba500df3
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 path = baker.getOutputPath(uri, page_num)
38 expected = '/destination/' + expected
39 assert expected == path
40