view tests/test_data_provider.py @ 975:a0a62d0da723

internal: Check that the `Assetor` has an asset URL format to work with.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 17 Oct 2017 01:08:56 -0700
parents 72f17534d58e
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