Mercurial > piecrust2
comparison tests/test_baking_baker.py @ 85:3471ffa059b2
Add a `BakeScheduler` to handle build dependencies. Add unit-tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 03 Sep 2014 17:27:50 -0700 |
parents | 7e44f6092a1d |
children | 133845647083 |
comparison
equal
deleted
inserted
replaced
84:b3ce11b2cf36 | 85:3471ffa059b2 |
---|---|
1 import os.path | 1 import os.path |
2 import pytest | 2 import pytest |
3 from piecrust.baking.baker import PageBaker | 3 from piecrust.baking.baker import PageBaker, Baker |
4 from .mockutil import get_mock_app | 4 from .mockutil import get_mock_app, mock_fs, mock_fs_scope |
5 | 5 |
6 | 6 |
7 @pytest.mark.parametrize('uri, page_num, pretty, expected', [ | 7 @pytest.mark.parametrize('uri, page_num, pretty, expected', [ |
8 # Pretty URLs | 8 # Pretty URLs |
9 ('', 1, True, 'index.html'), | 9 ('', 1, True, 'index.html'), |
43 path = baker.getOutputPath(sub_uri) | 43 path = baker.getOutputPath(sub_uri) |
44 expected = os.path.normpath( | 44 expected = os.path.normpath( |
45 os.path.join('/destination', expected)) | 45 os.path.join('/destination', expected)) |
46 assert expected == path | 46 assert expected == path |
47 | 47 |
48 | |
49 def test_empty_bake(): | |
50 fs = mock_fs() | |
51 with mock_fs_scope(fs): | |
52 assert not os.path.isdir(fs.path('kitchen/_counter')) | |
53 app = fs.getApp() | |
54 baker = Baker(app) | |
55 baker.bake() | |
56 assert os.path.isdir(fs.path('kitchen/_counter')) | |
57 structure = fs.getStructure('kitchen/_counter') | |
58 assert list(structure.keys()) == ['index.html'] | |
59 | |
60 | |
61 def test_simple_bake(): | |
62 fs = (mock_fs() | |
63 .withPage('posts/2010-01-01_post1.md', {'layout': 'none', 'format': 'none'}, 'post one') | |
64 .withPage('pages/_index.md', {'layout': 'none', 'format': 'none'}, "something")) | |
65 with mock_fs_scope(fs): | |
66 app = fs.getApp() | |
67 baker = Baker(app) | |
68 baker.bake() | |
69 structure = fs.getStructure('kitchen/_counter') | |
70 assert structure == { | |
71 '2010': {'01': {'01': {'post1.html': 'post one'}}}, | |
72 'index.html': 'something'} | |
73 |