Mercurial > piecrust2
annotate tests/test_sources_posts.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 | cb6eadea0845 |
children | e7b865f8f335 |
rev | line source |
---|---|
95
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import os |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 import pytest |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 from .mockutil import mock_fs, mock_fs_scope |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 @pytest.mark.parametrize('fs, src_type, expected_paths, expected_metadata', [ |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 (mock_fs(), 'flat', [], []), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 (mock_fs().withPage('test/2014-01-01_foo.md'), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 'flat', |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 ['2014-01-01_foo.md'], |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 [(2014, 1, 1, 'foo')]), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 (mock_fs(), 'shallow', [], []), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
13 (mock_fs().withPage('test/2014/01-01_foo.md'), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 'shallow', |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 ['2014/01-01_foo.md'], |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 [(2014, 1, 1, 'foo')]), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 (mock_fs(), 'hierarchy', [], []), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 (mock_fs().withPage('test/2014/01/01_foo.md'), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 'hierarchy', |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 ['2014/01/01_foo.md'], |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 [(2014, 1, 1, 'foo')]), |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 ]) |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 def test_post_source_factories(fs, src_type, expected_paths, expected_metadata): |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 fs.withConfig({ |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 'site': { |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
26 'sources': { |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
27 'test': {'type': 'posts/%s' % src_type}}, |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 'routes': [ |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 {'url': '/%slug%', 'source': 'test'}] |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
30 } |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
31 }) |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 fs.withDir('kitchen/test') |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 with mock_fs_scope(fs): |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
34 app = fs.getApp(cache=False) |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
35 s = app.getSource('test') |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 facs = list(s.buildPageFactories()) |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 paths = [f.rel_path for f in facs] |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 assert paths == expected_paths |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 metadata = [ |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
40 (f.metadata['year'], f.metadata['month'], |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
41 f.metadata['day'], f.metadata['slug']) |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
42 for f in facs] |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
43 assert metadata == expected_metadata |
cb6eadea0845
Fixed a bug with the `shallow` source. Add unit tests.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
44 |