comparison tests/test_processing_base.py @ 36:485682a6de50

New site layout support.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 20 Aug 2014 23:16:51 -0700
parents e4c345dcf33c
children 3471ffa059b2
comparison
equal deleted inserted replaced
35:e4c345dcf33c 36:485682a6de50
1 import os.path
1 import pytest 2 import pytest
2 from piecrust.processing.base import ProcessorPipeline 3 from piecrust.processing.base import ProcessorPipeline
3 from .mockutil import mock_fs, mock_fs_scope 4 from .mockutil import mock_fs, mock_fs_scope
4 5
5 6
6 def _get_pipeline(fs, **kwargs): 7 def _get_pipeline(fs, **kwargs):
7 return ProcessorPipeline(fs.getApp(), fs.path('counter'), 8 app = fs.getApp()
9 mounts = [os.path.join(app.root_dir, 'assets')]
10 return ProcessorPipeline(app, mounts, fs.path('counter'),
8 num_workers=1, **kwargs) 11 num_workers=1, **kwargs)
12
9 13
10 def test_empty(): 14 def test_empty():
11 fs = mock_fs() 15 fs = mock_fs()
12 with mock_fs_scope(fs): 16 with mock_fs_scope(fs):
13 pp = _get_pipeline(fs) 17 pp = _get_pipeline(fs)
19 assert expected == fs.getStructure('counter') 23 assert expected == fs.getStructure('counter')
20 24
21 25
22 def test_one_file(): 26 def test_one_file():
23 fs = (mock_fs() 27 fs = (mock_fs()
24 .withFile('kitchen/something.html', 'A test file.')) 28 .withFile('kitchen/assets/something.html', 'A test file.'))
25 with mock_fs_scope(fs): 29 with mock_fs_scope(fs):
26 pp = _get_pipeline(fs) 30 pp = _get_pipeline(fs)
27 pp.filterProcessors(['copy']) 31 pp.filterProcessors(['copy'])
28 expected = {} 32 expected = {}
29 assert expected == fs.getStructure('counter') 33 assert expected == fs.getStructure('counter')
41 {'something.html': 'A test file.', 45 {'something.html': 'A test file.',
42 'foo': {'_important.html': 'Important!'}}) 46 'foo': {'_important.html': 'Important!'}})
43 ]) 47 ])
44 def test_skip_pattern(patterns, expected): 48 def test_skip_pattern(patterns, expected):
45 fs = (mock_fs() 49 fs = (mock_fs()
46 .withFile('kitchen/something.html', 'A test file.') 50 .withFile('kitchen/assets/something.html', 'A test file.')
47 .withFile('kitchen/_hidden.html', 'Shhh') 51 .withFile('kitchen/assets/_hidden.html', 'Shhh')
48 .withFile('kitchen/foo/_important.html', 'Important!')) 52 .withFile('kitchen/assets/foo/_important.html', 'Important!'))
49 with mock_fs_scope(fs): 53 with mock_fs_scope(fs):
50 pp = _get_pipeline(fs, skip_patterns=['/^_/']) 54 pp = _get_pipeline(fs, skip_patterns=['/^_/'])
51 pp.filterProcessors(['copy']) 55 pp.filterProcessors(['copy'])
52 expected = {} 56 expected = {}
53 assert expected == fs.getStructure('counter') 57 assert expected == fs.getStructure('counter')