Mercurial > piecrust2
view tests/test_data_provider.py @ 852:4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
* Everything is a `ContentSource`, including assets directories.
* Most content sources are subclasses of the base file-system source.
* A source is processed by a "pipeline", and there are 2 built-in pipelines,
one for assets and one for pages. The asset pipeline is vaguely functional,
but the page pipeline is completely broken right now.
* Rewrite the baking process as just running appropriate pipelines on each
content item. This should allow for better parallelization.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 17 May 2017 00:11:48 -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