diff 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
line wrap: on
line diff
--- a/tests/test_sources_autoconfig.py	Sat Feb 17 11:51:45 2018 -0800
+++ b/tests/test_sources_autoconfig.py	Sat Feb 17 11:52:31 2018 -0800
@@ -77,7 +77,10 @@
             'test': {'type': 'autoconfig',
                      'setting_name': 'foo',
                      'only_single_values': True}
-        }
+        },
+        'routes': [
+            {'url': '/blah', 'source': 'test'}
+        ]
     }
     fs = mock_fs().withConfig({'site': site_config})
     fs.withPage('test/bar1/bar2/something.md')
@@ -140,30 +143,43 @@
 @pytest.mark.parametrize(
     'fs_fac, route_path, expected_path, expected_metadata',
     [
-        (lambda: mock_fs(), 'missing', None, None),
-        (lambda: mock_fs().withPage('test/something.md'),
-         'something', 'something.md',
-         {'slug': 'something',
-          'config': {'foo': 0, 'foo_trail': [0]}}),
-        (lambda: mock_fs().withPage('test/bar/something.md'),
-         'bar/something', 'bar/something.md',
-         {'slug': 'bar/something',
-          'config': {'foo': 0, 'foo_trail': [0]}}),
-        (lambda: mock_fs().withPage('test/42_something.md'),
-         'something', '42_something.md',
-         {'slug': 'something',
-          'config': {'foo': 42, 'foo_trail': [42]}}),
-        (lambda: mock_fs().withPage('test/bar/42_something.md'),
-         'bar/something', 'bar/42_something.md',
-         {'slug': 'bar/something',
-          'config': {'foo': 42, 'foo_trail': [42]}}),
-
-        ((lambda: mock_fs()
-          .withPage('test/42_something.md')
-          .withPage('test/43_other_something.md')),
-         'something', '42_something.md',
-         {'slug': 'something',
-          'config': {'foo': 42, 'foo_trail': [42]}}),
+        (
+            lambda: mock_fs(),
+            'missing',
+            None,
+            None),
+        (
+            lambda: mock_fs().withPage('test/something.html'),
+            'something',
+            'something.html',
+            {'route_params': {'slug': 'something'},
+             'config': {'foo': 0, 'foo_trail': [0]}}),
+        (
+            lambda: mock_fs().withPage('test/bar/something.html'),
+            'bar/something',
+            'bar/something.html',
+            {'route_params': {'slug': 'bar/something'},
+             'config': {'foo': 0, 'foo_trail': [0]}}),
+        (
+            lambda: mock_fs().withPage('test/42_something.html'),
+            'something',
+            '42_something.html',
+            {'route_params': {'slug': 'something'},
+             'config': {'foo': 42, 'foo_trail': [42]}}),
+        (
+            lambda: mock_fs().withPage('test/bar/42_something.html'),
+            'bar/something',
+            'bar/42_something.html',
+            {'route_params': {'slug': 'bar/something'},
+             'config': {'foo': 42, 'foo_trail': [42]}}),
+        (
+            (lambda: mock_fs()
+             .withPage('test/42_something.html')
+             .withPage('test/43_other_something.html')),
+            'something',
+            '42_something.html',
+            {'route_params': {'slug': 'something'},
+             'config': {'foo': 42, 'foo_trail': [42]}}),
     ])
 def test_ordered_source_find(fs_fac, route_path, expected_path,
                              expected_metadata):