Mercurial > piecrust2
comparison tests/test_serving.py @ 515:16e705c58cae
internal: Improve handling of taxonomy term slugification.
This paves the way to bring slugification options like transliteration to
PieCrust. This change mostly makes sure we use one-way slugification, which
means, for serving/previewing, we need to slugify each page's terms to compare
to the stuff captured from the URL. It also simplifies things a bit in the
code.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 26 Jul 2015 23:16:15 -0700 |
parents | b45322924d18 |
children | 64e696adb99e |
comparison
equal
deleted
inserted
replaced
514:c9c305645e5f | 515:16e705c58cae |
---|---|
75 with mock_fs_scope(fs): | 75 with mock_fs_scope(fs): |
76 app = fs.getApp() | 76 app = fs.getApp() |
77 page = app.getSource('pages').getPage({'slug': '_tag', 'tag': tag}) | 77 page = app.getSource('pages').getPage({'slug': '_tag', 'tag': tag}) |
78 route = app.getTaxonomyRoute('tags', 'posts') | 78 route = app.getTaxonomyRoute('tags', 'posts') |
79 route_metadata = {'slug': '_tag', 'tag': tag} | 79 route_metadata = {'slug': '_tag', 'tag': tag} |
80 taxonomy = app.getTaxonomy('tags') | |
81 | 80 |
82 qp = QualifiedPage(page, route, route_metadata) | 81 qp = QualifiedPage(page, route, route_metadata) |
83 ctx = PageRenderingContext(qp) | 82 ctx = PageRenderingContext(qp) |
84 ctx.setTaxonomyFilter(taxonomy, tag) | 83 ctx.setTaxonomyFilter(tag) |
85 rp = render_page(ctx) | 84 rp = render_page(ctx) |
86 | 85 |
87 expected = "Pages in %s\n" % tag | 86 expected = "Pages in %s\n" % tag |
88 if expected_indices: | 87 if expected_indices: |
89 for i in reversed(expected_indices): | 88 for i in reversed(expected_indices): |
120 app = fs.getApp() | 119 app = fs.getApp() |
121 page = app.getSource('pages').getPage({'slug': '_category', | 120 page = app.getSource('pages').getPage({'slug': '_category', |
122 'category': category}) | 121 'category': category}) |
123 route = app.getTaxonomyRoute('categories', 'posts') | 122 route = app.getTaxonomyRoute('categories', 'posts') |
124 route_metadata = {'slug': '_category', 'category': category} | 123 route_metadata = {'slug': '_category', 'category': category} |
125 taxonomy = app.getTaxonomy('categories') | |
126 | 124 |
127 qp = QualifiedPage(page, route, route_metadata) | 125 qp = QualifiedPage(page, route, route_metadata) |
128 ctx = PageRenderingContext(qp) | 126 ctx = PageRenderingContext(qp) |
129 ctx.setTaxonomyFilter(taxonomy, category) | 127 ctx.setTaxonomyFilter(category) |
130 rp = render_page(ctx) | 128 rp = render_page(ctx) |
131 | 129 |
132 expected = "Pages in %s\n" % category | 130 expected = "Pages in %s\n" % category |
133 if expected_indices: | 131 if expected_indices: |
134 for i in reversed(expected_indices): | 132 for i in reversed(expected_indices): |