Mercurial > piecrust2
comparison tests/test_data_provider.py @ 321:59d65654184e
tests: Add a blog data provider test.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 28 Mar 2015 14:26:14 -0700 |
parents | |
children | 4b1019bb2533 |
comparison
equal
deleted
inserted
replaced
320:edcc9dc17b37 | 321:59d65654184e |
---|---|
1 from piecrust.rendering import PageRenderingContext, render_page | |
2 from .mockutil import mock_fs, mock_fs_scope | |
3 | |
4 | |
5 def test_blog_provider(): | |
6 fs = (mock_fs() | |
7 .withPage('posts/2015-03-01_one.md', | |
8 {'title': 'One', 'category': 'Foo'}) | |
9 .withPage('posts/2015-03-02_two.md', | |
10 {'title': 'Two', 'category': 'Foo'}) | |
11 .withPage('posts/2015-03-03_three.md', | |
12 {'title': 'Three', 'category': 'Bar'}) | |
13 .withPage('pages/categories.md', | |
14 {'format': 'none', 'layout': 'none'}, | |
15 "{%for c in blog.categories%}\n" | |
16 "{{c.name}} ({{c.post_count}})\n" | |
17 "{%endfor%}\n")) | |
18 with mock_fs_scope(fs): | |
19 app = fs.getApp() | |
20 page = app.getSource('pages').getPage({'slug': 'categories'}) | |
21 ctx = PageRenderingContext(page, '/categories') | |
22 rp = render_page(ctx) | |
23 expected = "\nBar (1)\n\nFoo (2)\n" | |
24 assert rp.content == expected | |
25 |