annotate tests/test_baking_baker.py @ 989:8adc27285d93

bake: Big pass on bake performance. - Reduce the amount of data passed between processes. - Make inter-process data simple objects to make it easier to test with alternatives to pickle. - Make sources have the basic requirement to be able to find a content item from an item spec (path). - Make Hoedown the default Markdown formatter.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 19 Nov 2017 14:29:17 -0800
parents
children 1857dbd4580f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
989
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 import time
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2 from .mockutil import get_mock_app, mock_fs, mock_fs_scope
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 def test_bake_and_add_post():
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 fs = (mock_fs()
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 .withConfig()
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 .withPage('pages/_index.html', {'layout': 'none', 'format': 'none'},
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 "{% for p in pagination.posts -%}\n"
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 "{{p.title}}\n"
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11 "{% endfor %}")
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 .withPage('posts/2017-01-01_first.html', {'title': "First"},
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
13 "something"))
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
14 with mock_fs_scope(fs):
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
15 fs.runChef('bake')
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
16 structure = fs.getStructure('kitchen/_counter')
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17 assert structure['index.html'] == 'First\n'
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 time.sleep(1)
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 fs.withPage('posts/2017-01-02_second.html', {'title': "Second"},
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 "something else")
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22 fs.runChef('bake')
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 structure = fs.getStructure('kitchen/_counter')
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 assert structure['index.html'] == 'Second\nFirst\n'
8adc27285d93 bake: Big pass on bake performance.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
25