diff tests/test_sources_autoconfig.py @ 242:f130365568ff

internal: Code reorganization to put less stuff in `sources.base`. Interfaces that sources can implement are in `sources.interfaces`. The default page source is in `sources.default`. The `SimplePageSource` is gone since most subclasses only wanted to do *some* stuff the same, but *lots* of stuff slightly different. I may have to revisit the code to extract exactly the code that's in common.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 18 Feb 2015 18:35:03 -0800
parents f43f19975671
children f512905ae812
line wrap: on
line diff
--- a/tests/test_sources_autoconfig.py	Mon Feb 16 08:25:08 2015 -0800
+++ b/tests/test_sources_autoconfig.py	Wed Feb 18 18:35:03 2015 -0800
@@ -88,10 +88,16 @@
             (mock_fs(), [], []),
             (mock_fs().withPage('test/something.md'),
                 ['something.md'],
-                [{'slug': 'something', 'config': {'foo': 0}}]),
+                [{'slug': 'something',
+                    'config': {'foo': 0, 'foo_trail': [0]}}]),
             (mock_fs().withPage('test/08_something.md'),
                 ['08_something.md'],
-                [{'slug': 'something', 'config': {'foo': 8}}])
+                [{'slug': 'something',
+                    'config': {'foo': 8, 'foo_trail': [8]}}]),
+            (mock_fs().withPage('test/02_there/08_something.md'),
+                ['02_there/08_something.md'],
+                [{'slug': 'there/something',
+                    'config': {'foo': 8, 'foo_trail': [2, 8]}}]),
             ])
 def test_ordered_source_factories(fs, expected_paths, expected_metadata):
     site_config = {
@@ -120,22 +126,27 @@
             (mock_fs(), 'missing', None, None),
             (mock_fs().withPage('test/something.md'),
                 'something', 'something.md',
-                {'slug': 'something', 'config': {'foo': 0}}),
+                {'slug': 'something',
+                    'config': {'foo': 0, 'foo_trail': [0]}}),
             (mock_fs().withPage('test/bar/something.md'),
                 'bar/something', 'bar/something.md',
-                {'slug': 'bar/something', 'config': {'foo': 0}}),
+                {'slug': 'bar/something',
+                    'config': {'foo': 0, 'foo_trail': [0]}}),
             (mock_fs().withPage('test/42_something.md'),
                 'something', '42_something.md',
-                {'slug': 'something', 'config': {'foo': 42}}),
+                {'slug': 'something',
+                    'config': {'foo': 42, 'foo_trail': [42]}}),
             (mock_fs().withPage('test/bar/42_something.md'),
                 'bar/something', 'bar/42_something.md',
-                {'slug': 'bar/something', 'config': {'foo': 42}}),
+                {'slug': 'bar/something',
+                    'config': {'foo': 42, 'foo_trail': [42]}}),
 
             ((mock_fs()
                 .withPage('test/42_something.md')
                 .withPage('test/43_other_something.md')),
                 'something', '42_something.md',
-                {'slug': 'something', 'config': {'foo': 42}}),
+                {'slug': 'something',
+                    'config': {'foo': 42, 'foo_trail': [42]}}),
             ])
 def test_ordered_source_find(fs, route_path, expected_path,
                              expected_metadata):
@@ -152,7 +163,7 @@
     with mock_fs_scope(fs):
         app = fs.getApp()
         s = app.getSource('test')
-        route_metadata = {'path': route_path}
+        route_metadata = {'slug': route_path}
         fac_path, metadata = s.findPagePath(route_metadata, MODE_PARSING)
         assert fac_path == expected_path
         assert metadata == expected_metadata