comparison tests/test_data_provider.py @ 711:ab5c6a8ae90a

bake: Replace hard-coded taxonomy support with "generator" system. * Taxonomies are now implemented one or more `TaxonomyGenerator`s. * A `BlogArchivesGenerator` stub is there but non-functional.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 26 May 2016 19:52:47 -0700
parents f987b29d6fab
children 72f17534d58e
comparison
equal deleted inserted replaced
710:e85f29b28b84 711:ab5c6a8ae90a
4 4
5 def test_blog_provider(): 5 def test_blog_provider():
6 fs = (mock_fs() 6 fs = (mock_fs()
7 .withConfig() 7 .withConfig()
8 .withPage('posts/2015-03-01_one.md', 8 .withPage('posts/2015-03-01_one.md',
9 {'title': 'One', 'category': 'Foo'}) 9 {'title': 'One', 'tags': ['Foo']})
10 .withPage('posts/2015-03-02_two.md', 10 .withPage('posts/2015-03-02_two.md',
11 {'title': 'Two', 'category': 'Foo'}) 11 {'title': 'Two', 'tags': ['Foo']})
12 .withPage('posts/2015-03-03_three.md', 12 .withPage('posts/2015-03-03_three.md',
13 {'title': 'Three', 'category': 'Bar'}) 13 {'title': 'Three', 'tags': ['Bar']})
14 .withPage('pages/categories.md', 14 .withPage('pages/tags.md',
15 {'format': 'none', 'layout': 'none'}, 15 {'format': 'none', 'layout': 'none'},
16 "{%for c in blog.categories%}\n" 16 "{%for c in blog.tags%}\n"
17 "{{c.name}} ({{c.post_count}})\n" 17 "{{c.name}} ({{c.post_count}})\n"
18 "{%endfor%}\n")) 18 "{%endfor%}\n"))
19 with mock_fs_scope(fs): 19 with mock_fs_scope(fs):
20 app = fs.getApp() 20 app = fs.getApp()
21 page = app.getSource('pages').getPage({'slug': 'categories'}) 21 page = app.getSource('pages').getPage({'slug': 'tags'})
22 route = app.getRoute('pages', None) 22 route = app.getSourceRoute('pages', None)
23 route_metadata = {'slug': 'categories'} 23 route_metadata = {'slug': 'tags'}
24 qp = QualifiedPage(page, route, route_metadata) 24 qp = QualifiedPage(page, route, route_metadata)
25 ctx = PageRenderingContext(qp) 25 ctx = PageRenderingContext(qp)
26 rp = render_page(ctx) 26 rp = render_page(ctx)
27 expected = "\nBar (1)\n\nFoo (2)\n" 27 expected = "\nBar (1)\n\nFoo (2)\n"
28 assert rp.content == expected 28 assert rp.content == expected