Mercurial > piecrust2
diff tests/test_sources_posts.py @ 979:45ad976712ec
tests: Big push to get the tests to pass again.
- Lots of fixes everywhere in the code.
- Try to handle debug logging in the multiprocessing worker pool when running in pytest. Not perfect, but usable for now.
- Replace all `.md` test files with `.html` since now a auto-format extension always sets the format.
- Replace `out` with `outfiles` in most places since now blog archives are added to the bake output and I don't want to add expected outputs for blog archives everywhere.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 29 Oct 2017 22:51:57 -0700 |
parents | e7b865f8f335 |
children | 22e767899e52 |
line wrap: on
line diff
--- a/tests/test_sources_posts.py Sun Oct 29 22:46:41 2017 -0700 +++ b/tests/test_sources_posts.py Sun Oct 29 22:51:57 2017 -0700 @@ -1,8 +1,11 @@ +import os.path import pytest from .mockutil import mock_fs, mock_fs_scope -@pytest.mark.parametrize('fs_fac, src_type, expected_paths, expected_metadata', [ +@pytest.mark.parametrize( + 'fs_fac, src_type, expected_paths, expected_metadata', + [ (lambda: mock_fs(), 'flat', [], []), (lambda: mock_fs().withPage('test/2014-01-01_foo.md'), 'flat', @@ -18,9 +21,9 @@ 'hierarchy', ['2014/01/01_foo.md'], [(2014, 1, 1, 'foo')]), - ]) -def test_post_source_factories(fs_fac, src_type, expected_paths, - expected_metadata): + ]) +def test_post_source_items(fs_fac, src_type, expected_paths, + expected_metadata): fs = fs_fac() fs.withConfig({ 'site': { @@ -28,18 +31,20 @@ 'test': {'type': 'posts/%s' % src_type}}, 'routes': [ {'url': '/%slug%', 'source': 'test'}] - } - }) + } + }) fs.withDir('kitchen/test') with mock_fs_scope(fs): - app = fs.getApp(cache=False) + app = fs.getApp() s = app.getSource('test') - facs = list(s.buildPageFactories()) - paths = [f.rel_path for f in facs] + items = list(s.getAllContents()) + paths = [os.path.relpath(f.spec, s.fs_endpoint_path) for f in items] assert paths == expected_paths metadata = [ - (f.metadata['year'], f.metadata['month'], - f.metadata['day'], f.metadata['slug']) - for f in facs] + (f.metadata['route_params']['year'], + f.metadata['route_params']['month'], + f.metadata['route_params']['day'], + f.metadata['route_params']['slug']) + for f in items] assert metadata == expected_metadata