Mercurial > piecrust2
annotate tests/test_data_provider.py @ 334:b034f6f15e22
bake: Several bug taxonomy-related fixes for incorrect incremental bakes.
* Improve how the baker processes taxonomy terms and figures out what needs
to be re-baked or not.
* Create bake entries for clean taxnomy terms so they're not deleted by an
incremental bake.
* Add more information to bake records.
* Slugify taxonomy terms is now done by the route in one place.
* Fix a bug where the cache key for invalidating rendered segments was not
computed the same way as when the caching was done.
* Fix how term combinations are passed around, rendered, printed, parsed, etc.
(TODO: more word needed in the routing functions)
* Expose to the template whether a taxonomy term is a combination or not.
* Display term combinations better in the built-in theme.
* Rename `route.taxonomy` to `route.taxonomy_name` to prevent confusion.
* Add options to show bake records for previous bakes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 03 Apr 2015 10:59:50 -0700 |
parents | 59d65654184e |
children | 4b1019bb2533 |
rev | line source |
---|---|
321
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 from piecrust.rendering import PageRenderingContext, render_page |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 from .mockutil import mock_fs, mock_fs_scope |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 def test_blog_provider(): |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 fs = (mock_fs() |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 .withPage('posts/2015-03-01_one.md', |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 {'title': 'One', 'category': 'Foo'}) |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 .withPage('posts/2015-03-02_two.md', |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 {'title': 'Two', 'category': 'Foo'}) |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 .withPage('posts/2015-03-03_three.md', |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 {'title': 'Three', 'category': 'Bar'}) |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 .withPage('pages/categories.md', |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 {'format': 'none', 'layout': 'none'}, |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 "{%for c in blog.categories%}\n" |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 "{{c.name}} ({{c.post_count}})\n" |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 "{%endfor%}\n")) |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 with mock_fs_scope(fs): |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 app = fs.getApp() |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 page = app.getSource('pages').getPage({'slug': 'categories'}) |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 ctx = PageRenderingContext(page, '/categories') |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 rp = render_page(ctx) |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 expected = "\nBar (1)\n\nFoo (2)\n" |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 assert rp.content == expected |
59d65654184e
tests: Add a blog data provider test.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 |