Mercurial > piecrust2
view tests/test_data_provider.py @ 974:72f17534d58e
tests: First pass on making unit tests work again.
- Fix all imports
- Add more helper functions to work with mock file-systems
- Simplify some code by running chef directly on the mock FS
- Fix a couple tests
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 17 Oct 2017 01:07:30 -0700 |
parents | ab5c6a8ae90a |
children |
line wrap: on
line source
from .mockutil import mock_fs, mock_fs_scope from .rdrutil import render_simple_page 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.getSimplePage('tags.md') actual = render_simple_page(page) expected = "\nBar (1)\n\nFoo (2)\n" assert actual == expected