view 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
line wrap: on
line source

import time
from .mockutil import get_mock_app, mock_fs, mock_fs_scope


def test_bake_and_add_post():
    fs = (mock_fs()
          .withConfig()
          .withPage('pages/_index.html', {'layout': 'none', 'format': 'none'},
                    "{% for p in pagination.posts -%}\n"
                    "{{p.title}}\n"
                    "{% endfor %}")
          .withPage('posts/2017-01-01_first.html', {'title': "First"},
                    "something"))
    with mock_fs_scope(fs):
        fs.runChef('bake')
        structure = fs.getStructure('kitchen/_counter')
        assert structure['index.html'] == 'First\n'

        time.sleep(1)
        fs.withPage('posts/2017-01-02_second.html', {'title': "Second"},
                    "something else")
        fs.runChef('bake')
        structure = fs.getStructure('kitchen/_counter')
        assert structure['index.html'] == 'Second\nFirst\n'