diff tests/test_sources_base.py @ 363:dd25bd3ce1f9

serve: Refactoring and fixes to be able to serve taxonomy pages. * Page sources' `findPagePath` is renamed to `findPageFactory`, so that it also returns source metadata. * Page refs now store possible hits more properly, and use the previous point to also store metadata. As a result, they can also return a proper factory. * Implement `findPageFactory` correctly in all built-in sources. * When the Chef server matches a taxonomy page, get the source metadata from the page ref in order to make a more proper page. * Make the `getRoute(s)` functions explicitely say if they want taxonomy routes or not.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 26 Apr 2015 15:07:40 -0700
parents a2d283d1033d
children e7b865f8f335
line wrap: on
line diff
--- a/tests/test_sources_base.py	Sun Apr 26 08:34:27 2015 -0700
+++ b/tests/test_sources_base.py	Sun Apr 26 15:07:40 2015 -0700
@@ -41,12 +41,15 @@
         assert slugs == expected_slugs
 
 
-
-@pytest.mark.parametrize('ref_path, expected', [
-        ('foo.html', '/kitchen/test/foo.html'),
-        ('foo/bar.html', '/kitchen/test/foo/bar.html'),
+@pytest.mark.parametrize(
+        'ref_path, expected_path, expected_metadata',
+        [
+            ('foo.html', '/kitchen/test/foo.html', {'slug': 'foo'}),
+            ('foo/bar.html', '/kitchen/test/foo/bar.html',
+                {'slug': 'foo/bar'}),
         ])
-def test_default_source_resolve_ref(ref_path, expected):
+def test_default_source_resolve_ref(ref_path, expected_path,
+                                    expected_metadata):
     fs = mock_fs()
     fs.withConfig({
         'site': {
@@ -56,12 +59,13 @@
                 {'url': '/%path%', 'source': 'test'}]
             }
         })
-    expected = fs.path(expected).replace('/', os.sep)
+    expected_path = fs.path(expected_path).replace('/', os.sep)
     with mock_fs_scope(fs):
         app = PieCrust(fs.path('kitchen'), cache=False)
         s = app.getSource('test')
-        actual = s.resolveRef(ref_path)
-        assert actual == expected
+        actual_path, actual_metadata = s.resolveRef(ref_path)
+        assert actual_path == expected_path
+        assert actual_metadata == expected_metadata
 
 
 @pytest.mark.parametrize('page_ref, expected_source_name, expected_rel_path, '