comparison tests/test_sources_autoconfig.py @ 1098:2323f0788170

config: Report error if a non-asset source has no URL route.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 17 Feb 2018 11:52:31 -0800
parents 8adc27285d93
children
comparison
equal deleted inserted replaced
1097:2b2eaee96121 1098:2323f0788170
75 site_config = { 75 site_config = {
76 'sources': { 76 'sources': {
77 'test': {'type': 'autoconfig', 77 'test': {'type': 'autoconfig',
78 'setting_name': 'foo', 78 'setting_name': 'foo',
79 'only_single_values': True} 79 'only_single_values': True}
80 } 80 },
81 'routes': [
82 {'url': '/blah', 'source': 'test'}
83 ]
81 } 84 }
82 fs = mock_fs().withConfig({'site': site_config}) 85 fs = mock_fs().withConfig({'site': site_config})
83 fs.withPage('test/bar1/bar2/something.md') 86 fs.withPage('test/bar1/bar2/something.md')
84 with mock_fs_scope(fs): 87 with mock_fs_scope(fs):
85 app = fs.getApp() 88 app = fs.getApp()
138 141
139 142
140 @pytest.mark.parametrize( 143 @pytest.mark.parametrize(
141 'fs_fac, route_path, expected_path, expected_metadata', 144 'fs_fac, route_path, expected_path, expected_metadata',
142 [ 145 [
143 (lambda: mock_fs(), 'missing', None, None), 146 (
144 (lambda: mock_fs().withPage('test/something.md'), 147 lambda: mock_fs(),
145 'something', 'something.md', 148 'missing',
146 {'slug': 'something', 149 None,
147 'config': {'foo': 0, 'foo_trail': [0]}}), 150 None),
148 (lambda: mock_fs().withPage('test/bar/something.md'), 151 (
149 'bar/something', 'bar/something.md', 152 lambda: mock_fs().withPage('test/something.html'),
150 {'slug': 'bar/something', 153 'something',
151 'config': {'foo': 0, 'foo_trail': [0]}}), 154 'something.html',
152 (lambda: mock_fs().withPage('test/42_something.md'), 155 {'route_params': {'slug': 'something'},
153 'something', '42_something.md', 156 'config': {'foo': 0, 'foo_trail': [0]}}),
154 {'slug': 'something', 157 (
155 'config': {'foo': 42, 'foo_trail': [42]}}), 158 lambda: mock_fs().withPage('test/bar/something.html'),
156 (lambda: mock_fs().withPage('test/bar/42_something.md'), 159 'bar/something',
157 'bar/something', 'bar/42_something.md', 160 'bar/something.html',
158 {'slug': 'bar/something', 161 {'route_params': {'slug': 'bar/something'},
159 'config': {'foo': 42, 'foo_trail': [42]}}), 162 'config': {'foo': 0, 'foo_trail': [0]}}),
160 163 (
161 ((lambda: mock_fs() 164 lambda: mock_fs().withPage('test/42_something.html'),
162 .withPage('test/42_something.md') 165 'something',
163 .withPage('test/43_other_something.md')), 166 '42_something.html',
164 'something', '42_something.md', 167 {'route_params': {'slug': 'something'},
165 {'slug': 'something', 168 'config': {'foo': 42, 'foo_trail': [42]}}),
166 'config': {'foo': 42, 'foo_trail': [42]}}), 169 (
170 lambda: mock_fs().withPage('test/bar/42_something.html'),
171 'bar/something',
172 'bar/42_something.html',
173 {'route_params': {'slug': 'bar/something'},
174 'config': {'foo': 42, 'foo_trail': [42]}}),
175 (
176 (lambda: mock_fs()
177 .withPage('test/42_something.html')
178 .withPage('test/43_other_something.html')),
179 'something',
180 '42_something.html',
181 {'route_params': {'slug': 'something'},
182 'config': {'foo': 42, 'foo_trail': [42]}}),
167 ]) 183 ])
168 def test_ordered_source_find(fs_fac, route_path, expected_path, 184 def test_ordered_source_find(fs_fac, route_path, expected_path,
169 expected_metadata): 185 expected_metadata):
170 site_config = { 186 site_config = {
171 'sources': { 187 'sources': {