mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Cleaned up tests.
Used assertItemsEqual in article generation to create more precise tests than with an elif chain Separated out categories out into their own named test for clarity Closes #405
This commit is contained in:
parent
63f37eeeda
commit
9435b381ed
1 changed files with 18 additions and 21 deletions
|
|
@ -63,29 +63,26 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
|
|
||||||
def test_generate_context(self):
|
def test_generate_context(self):
|
||||||
|
|
||||||
settings = _DEFAULT_CONFIG.copy()
|
generator = self.get_populated_generator()
|
||||||
settings['ARTICLE_DIR'] = 'content'
|
articles = self.distill_articles(generator.articles)
|
||||||
settings['DEFAULT_CATEGORY'] = 'Default'
|
articles_expected = [
|
||||||
generator = ArticlesGenerator(settings.copy(), settings, CUR_DIR,
|
[u'Article title', 'published', 'Default', 'article'],
|
||||||
_DEFAULT_CONFIG['THEME'], None,
|
[u'Article with template', 'published', 'Default', 'custom'],
|
||||||
_DEFAULT_CONFIG['MARKUP'])
|
[u'Test md File', 'published', 'test', 'article'],
|
||||||
generator.generate_context()
|
[u'This is a super article !', 'published', 'Yeah', 'article'],
|
||||||
for article in generator.articles:
|
[u'This is an article with category !', 'published', 'yeah', 'article'],
|
||||||
relfilepath = os.path.relpath(article.filename, CUR_DIR)
|
[u'This is an article without category !', 'published', 'Default', 'article'],
|
||||||
if relfilepath == os.path.join("TestCategory",
|
[u'This is an article without category !', 'published', 'TestCategory', 'article'],
|
||||||
"article_with_category.rst"):
|
[u'This is a super article !', 'published', 'yeah', 'article']
|
||||||
self.assertEquals(article.category.name, 'yeah')
|
]
|
||||||
elif relfilepath == os.path.join("TestCategory",
|
self.assertItemsEqual(articles_expected, articles)
|
||||||
"article_without_category.rst"):
|
|
||||||
self.assertEquals(article.category.name, 'TestCategory')
|
|
||||||
elif relfilepath == "article_without_category.rst":
|
|
||||||
self.assertEquals(article.category.name, 'Default')
|
|
||||||
|
|
||||||
|
def test_generate_categories(self):
|
||||||
|
|
||||||
|
generator = self.get_populated_generator()
|
||||||
categories = [cat.name for cat, _ in generator.categories]
|
categories = [cat.name for cat, _ in generator.categories]
|
||||||
# assert that the categories are ordered as expected
|
categories_expected = ['Default', 'TestCategory', 'Yeah', 'test', 'yeah']
|
||||||
self.assertEquals(
|
self.assertEquals(categories, categories_expected)
|
||||||
categories, ['Default', 'TestCategory', 'Yeah', 'test',
|
|
||||||
'yeah'])
|
|
||||||
|
|
||||||
def test_direct_templates_save_as_default(self):
|
def test_direct_templates_save_as_default(self):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue