Mercurial > piecrust2
view tests/test_data_provider.py @ 935:7ecb946bfafd
admin: Lots of fixes for running the admin panel in a WSGI server.
- Use new source APIs in the dashboard to open WIP files.
- Fixed broken/outdated code in some views.
- Fixed cases when Flask is not running at the root URL by using the
`SCRIPT_NAME` variable somewhat more properly.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Oct 2017 09:15:16 -0700 |
parents | ab5c6a8ae90a |
children | 72f17534d58e |
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() .withConfig() .withPage('posts/2015-03-01_one.md', {'title': 'One', 'tags': ['Foo']}) .withPage('posts/2015-03-02_two.md', {'title': 'Two', 'tags': ['Foo']}) .withPage('posts/2015-03-03_three.md', {'title': 'Three', 'tags': ['Bar']}) .withPage('pages/tags.md', {'format': 'none', 'layout': 'none'}, "{%for c in blog.tags%}\n" "{{c.name}} ({{c.post_count}})\n" "{%endfor%}\n")) with mock_fs_scope(fs): app = fs.getApp() page = app.getSource('pages').getPage({'slug': 'tags'}) route = app.getSourceRoute('pages', None) route_metadata = {'slug': 'tags'} qp = QualifiedPage(page, route, route_metadata) ctx = PageRenderingContext(qp) rp = render_page(ctx) expected = "\nBar (1)\n\nFoo (2)\n" assert rp.content == expected