Mercurial > piecrust2
view tests/test_page.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 | 474c9882decf |
children | 72f17534d58e |
line wrap: on
line source
import pytest from piecrust.page import parse_segments test_parse_segments_data1 = ("", {'content': ''}) test_parse_segments_data2 = ("Foo bar", {'content': 'Foo bar'}) test_parse_segments_data3 = ("""Something that spans several lines like this""", {'content': """Something that spans several lines like this"""}) test_parse_segments_data4 = ("""Blah blah ---foo--- Something else ---bar--- Last thing """, { 'content': "Blah blah\n", 'foo': "Something else\n", 'bar': "Last thing\n"}) test_parse_segments_data5 = ("""Blah blah <--textile--> Here's some textile """, { 'content': [ ("Blah blah\n", None), ("Here's some textile\n", 'textile')]}) test_parse_segments_data6 = ("""Blah blah Whatever <--textile--> Oh well, that's good ---foo--- Another segment With another... <--change--> ...of formatting. """, { 'content': [ ("Blah blah\nWhatever\n", None), ("Oh well, that's good\n", 'textile')], 'foo': [ ("Another segment\nWith another...\n", None), ("...of formatting.\n", 'change')]}) @pytest.mark.parametrize('text, expected', [ test_parse_segments_data1, test_parse_segments_data2, test_parse_segments_data3, test_parse_segments_data4, test_parse_segments_data5, test_parse_segments_data6, ]) def test_parse_segments(text, expected): actual = parse_segments(text) assert actual is not None assert list(actual.keys()) == list(expected.keys()) for key, val in expected.items(): if isinstance(val, str): assert len(actual[key].parts) == 1 assert actual[key].parts[0].content == val assert actual[key].parts[0].fmt is None else: assert len(actual[key].parts) == len(val) for i, part in enumerate(val): assert actual[key].parts[i].content == part[0] assert actual[key].parts[i].fmt == part[1]