Mercurial > piecrust2
comparison tests/test_processing_base.py @ 674:f987b29d6fab
tests: Add ability to run tests with a theme site.
* Remove automatic creating of `config.yml`.
* Add option to specify `theme_config` in YAML tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 06 Mar 2016 23:48:01 -0800 |
parents | c9c305645e5f |
children |
comparison
equal
deleted
inserted
replaced
673:d6403c21bdea | 674:f987b29d6fab |
---|---|
40 app = app or fs.getApp() | 40 app = app or fs.getApp() |
41 return ProcessorPipeline(app, fs.path('counter')) | 41 return ProcessorPipeline(app, fs.path('counter')) |
42 | 42 |
43 | 43 |
44 def test_empty(): | 44 def test_empty(): |
45 fs = mock_fs() | 45 fs = (mock_fs() |
46 .withDir('counter') | |
47 .withConfig()) | |
46 with mock_fs_scope(fs): | 48 with mock_fs_scope(fs): |
47 pp = _get_pipeline(fs) | 49 pp = _get_pipeline(fs) |
48 pp.enabled_processors = ['copy'] | 50 pp.enabled_processors = ['copy'] |
49 expected = {} | 51 expected = {} |
50 assert expected == fs.getStructure('counter') | 52 assert expected == fs.getStructure('counter') |
53 assert expected == fs.getStructure('counter') | 55 assert expected == fs.getStructure('counter') |
54 | 56 |
55 | 57 |
56 def test_one_file(): | 58 def test_one_file(): |
57 fs = (mock_fs() | 59 fs = (mock_fs() |
60 .withDir('counter') | |
61 .withConfig() | |
58 .withFile('kitchen/assets/something.html', 'A test file.')) | 62 .withFile('kitchen/assets/something.html', 'A test file.')) |
59 with mock_fs_scope(fs): | 63 with mock_fs_scope(fs): |
60 pp = _get_pipeline(fs) | 64 pp = _get_pipeline(fs) |
61 pp.enabled_processors = ['copy'] | 65 pp.enabled_processors = ['copy'] |
62 expected = {} | 66 expected = {} |
66 assert expected == fs.getStructure('counter') | 70 assert expected == fs.getStructure('counter') |
67 | 71 |
68 | 72 |
69 def test_one_level_dirtyness(): | 73 def test_one_level_dirtyness(): |
70 fs = (mock_fs() | 74 fs = (mock_fs() |
75 .withConfig() | |
71 .withFile('kitchen/assets/blah.foo', 'A test file.')) | 76 .withFile('kitchen/assets/blah.foo', 'A test file.')) |
72 with mock_fs_scope(fs): | 77 with mock_fs_scope(fs): |
73 pp = _get_pipeline(fs) | 78 pp = _get_pipeline(fs) |
74 pp.enabled_processors = ['copy'] | 79 pp.enabled_processors = ['copy'] |
75 pp.run() | 80 pp.run() |
91 assert mtime < os.path.getmtime(fs.path('/counter/blah.foo')) | 96 assert mtime < os.path.getmtime(fs.path('/counter/blah.foo')) |
92 | 97 |
93 | 98 |
94 def test_two_levels_dirtyness(): | 99 def test_two_levels_dirtyness(): |
95 fs = (mock_fs() | 100 fs = (mock_fs() |
101 .withConfig() | |
96 .withFile('kitchen/assets/blah.foo', 'A test file.')) | 102 .withFile('kitchen/assets/blah.foo', 'A test file.')) |
97 with mock_fs_scope(fs): | 103 with mock_fs_scope(fs): |
98 pp = _get_pipeline(fs) | 104 pp = _get_pipeline(fs) |
99 pp.enabled_processors = ['copy'] | 105 pp.enabled_processors = ['copy'] |
100 pp.additional_processors_factories = [ | 106 pp.additional_processors_factories = [ |
118 assert mtime < os.path.getmtime(fs.path('/counter/blah.bar')) | 124 assert mtime < os.path.getmtime(fs.path('/counter/blah.bar')) |
119 | 125 |
120 | 126 |
121 def test_removed(): | 127 def test_removed(): |
122 fs = (mock_fs() | 128 fs = (mock_fs() |
129 .withConfig() | |
123 .withFile('kitchen/assets/blah1.foo', 'A test file.') | 130 .withFile('kitchen/assets/blah1.foo', 'A test file.') |
124 .withFile('kitchen/assets/blah2.foo', 'Ooops')) | 131 .withFile('kitchen/assets/blah2.foo', 'Ooops')) |
125 with mock_fs_scope(fs): | 132 with mock_fs_scope(fs): |
126 expected = { | 133 expected = { |
127 'blah1.foo': 'A test file.', | 134 'blah1.foo': 'A test file.', |
141 assert expected == fs.getStructure('counter') | 148 assert expected == fs.getStructure('counter') |
142 | 149 |
143 | 150 |
144 def test_record_version_change(): | 151 def test_record_version_change(): |
145 fs = (mock_fs() | 152 fs = (mock_fs() |
153 .withConfig() | |
146 .withFile('kitchen/assets/blah.foo', 'A test file.')) | 154 .withFile('kitchen/assets/blah.foo', 'A test file.')) |
147 with mock_fs_scope(fs): | 155 with mock_fs_scope(fs): |
148 pp = _get_pipeline(fs) | 156 pp = _get_pipeline(fs) |
149 pp.enabled_processors = ['copy'] | 157 pp.enabled_processors = ['copy'] |
150 pp.additional_processors_factories = [ | 158 pp.additional_processors_factories = [ |
175 {'something.html': 'A test file.', | 183 {'something.html': 'A test file.', |
176 'foo': {'_important.html': 'Important!'}}) | 184 'foo': {'_important.html': 'Important!'}}) |
177 ]) | 185 ]) |
178 def test_ignore_pattern(patterns, expected): | 186 def test_ignore_pattern(patterns, expected): |
179 fs = (mock_fs() | 187 fs = (mock_fs() |
188 .withDir('counter') | |
189 .withConfig() | |
180 .withFile('kitchen/assets/something.html', 'A test file.') | 190 .withFile('kitchen/assets/something.html', 'A test file.') |
181 .withFile('kitchen/assets/_hidden.html', 'Shhh') | 191 .withFile('kitchen/assets/_hidden.html', 'Shhh') |
182 .withFile('kitchen/assets/foo/_important.html', 'Important!')) | 192 .withFile('kitchen/assets/foo/_important.html', 'Important!')) |
183 with mock_fs_scope(fs): | 193 with mock_fs_scope(fs): |
184 pp = _get_pipeline(fs) | 194 pp = _get_pipeline(fs) |
199 'pygments_style']), | 209 'pygments_style']), |
200 ('copy', ['copy']), | 210 ('copy', ['copy']), |
201 ('less sass', ['less', 'sass']) | 211 ('less sass', ['less', 'sass']) |
202 ]) | 212 ]) |
203 def test_filter_processor(names, expected): | 213 def test_filter_processor(names, expected): |
204 fs = mock_fs() | 214 fs = mock_fs().withConfig() |
205 with mock_fs_scope(fs): | 215 with mock_fs_scope(fs): |
206 app = fs.getApp() | 216 app = fs.getApp() |
207 processors = app.plugin_loader.getProcessors() | 217 processors = app.plugin_loader.getProcessors() |
208 procs = get_filtered_processors(processors, names) | 218 procs = get_filtered_processors(processors, names) |
209 actual = [p.PROCESSOR_NAME for p in procs] | 219 actual = [p.PROCESSOR_NAME for p in procs] |