Mercurial > piecrust2
view tests/test_data_provider.py @ 853:f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
The asset pipeline is still the only function pipeline at this point.
* No more `QualifiedPage`, and several other pieces of code deleted.
* Data providers are simpler and more focused. For instance, the page iterator
doesn't try to support other types of items.
* Route parameters are proper known source metadata to remove the confusion
between the two.
* Make the baker and pipeline more correctly manage records and record
histories.
* Add support for record collapsing and deleting stale outputs in the asset
pipeline.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 21 May 2017 00:06:59 -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