mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add per page templates. Closes #376
Also set up helper classes in test_generators.py for cleaner tests
This commit is contained in:
parent
4c060030ae
commit
dff5b3589b
8 changed files with 128 additions and 15 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from .support import unittest
|
||||
|
||||
from pelican.contents import Page
|
||||
from pelican.contents import Page, Article
|
||||
from pelican.settings import _DEFAULT_CONFIG
|
||||
from pelican.utils import truncate_html_words
|
||||
|
||||
|
|
@ -135,6 +135,17 @@ class TestPage(unittest.TestCase):
|
|||
# will simply skip this test.
|
||||
unittest.skip("There is no locale %s in this system." % locale)
|
||||
|
||||
def test_template(self):
|
||||
"""
|
||||
Pages default to page, metadata overwrites
|
||||
"""
|
||||
default_page = Page(**self.page_kwargs)
|
||||
self.assertEqual('page', default_page.template)
|
||||
page_kwargs = self._copy_page_kwargs()
|
||||
page_kwargs['metadata']['template'] = 'custom'
|
||||
custom_page = Page(**page_kwargs)
|
||||
self.assertEqual('custom', custom_page.template)
|
||||
|
||||
def _copy_page_kwargs(self):
|
||||
# make a deep copy of page_kwargs
|
||||
page_kwargs = dict([(key, self.page_kwargs[key]) for key in
|
||||
|
|
@ -146,3 +157,15 @@ class TestPage(unittest.TestCase):
|
|||
for subkey in page_kwargs[key]])
|
||||
|
||||
return page_kwargs
|
||||
|
||||
class TestArticle(TestPage):
|
||||
def test_template(self):
|
||||
"""
|
||||
Articles default to article, metadata overwrites
|
||||
"""
|
||||
default_article = Article(**self.page_kwargs)
|
||||
self.assertEqual('article', default_article.template)
|
||||
article_kwargs = self._copy_page_kwargs()
|
||||
article_kwargs['metadata']['template'] = 'custom'
|
||||
custom_article = Article(**article_kwargs)
|
||||
self.assertEqual('custom', custom_article.template)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue