Mercurial > piecrust2
view tests/test_data_provider.py @ 552:9612cfc6455a
serve: Rewrite of the Server-Sent Event code for build notifications.
At the moment the server monitors the asset directories, and notifies the
browser when an asset has changed and has been re-processed.
* Fix issues around long-running requests/threads which mess up the ability
to shutdown the server correctly with `CTRL-C` (see comments in code).
* Move the notification queue to each SSE producer, to support having multiple
pages open in a browser.
* Add JS/CSS for showing quick notifications about re-processed assets.
* Add support for hot-reloading CSS and pictures that have been re-processed.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 08 Aug 2015 16:12:04 -0700 |
parents | 4b1019bb2533 |
children | f987b29d6fab |
line wrap: on
line source
from piecrust.rendering import QualifiedPage, PageRenderingContext, render_page from .mockutil import mock_fs, mock_fs_scope def test_blog_provider(): fs = (mock_fs() .withPage('posts/2015-03-01_one.md', {'title': 'One', 'category': 'Foo'}) .withPage('posts/2015-03-02_two.md', {'title': 'Two', 'category': 'Foo'}) .withPage('posts/2015-03-03_three.md', {'title': 'Three', 'category': 'Bar'}) .withPage('pages/categories.md', {'format': 'none', 'layout': 'none'}, "{%for c in blog.categories%}\n" "{{c.name}} ({{c.post_count}})\n" "{%endfor%}\n")) with mock_fs_scope(fs): app = fs.getApp() page = app.getSource('pages').getPage({'slug': 'categories'}) route = app.getRoute('pages', None) route_metadata = {'slug': 'categories'} qp = QualifiedPage(page, route, route_metadata) ctx = PageRenderingContext(qp) rp = render_page(ctx) expected = "\nBar (1)\n\nFoo (2)\n" assert rp.content == expected