1
0
Fork 0
forked from github/pelican

Add tests for Pelican and pelican_import tool

Added tests to ensure that:
- THEME and deprecated *_DIR settings result in the expected configurations
- Post headers are formatted correctly in both Markdown and reStructuredText
- Files specified in IGNORE_FILES setting are properly ignored
- Generator.get_files()'s `paths` argument is backwards-compatible with strings
This commit is contained in:
Kevin Yap 2014-11-03 21:00:09 -08:00
commit 6549f51591
3 changed files with 90 additions and 8 deletions

View file

@ -245,6 +245,41 @@ class TestBuildHeader(unittest.TestCase):
header = build_header('test', None, None, None, None, None)
self.assertEqual(header, 'test\n####\n\n')
def test_build_header_with_fields(self):
header_data = [
'Test Post',
'2014-11-04',
'Alexis Métaireau',
['Programming'],
['Pelican', 'Python'],
'test-post',
]
expected_docutils = '\n'.join([
'Test Post',
'#########',
':date: 2014-11-04',
':author: Alexis Métaireau',
':category: Programming',
':tags: Pelican, Python',
':slug: test-post',
'\n',
])
expected_md = '\n'.join([
'Title: Test Post',
'Date: 2014-11-04',
'Author: Alexis Métaireau',
'Category: Programming',
'Tags: Pelican, Python',
'Slug: test-post',
'\n',
])
self.assertEqual(build_header(*header_data), expected_docutils)
self.assertEqual(build_markdown_header(*header_data), expected_md)
def test_build_header_with_east_asian_characters(self):
header = build_header('これは広い幅の文字だけで構成されたタイトルです',
None, None, None, None, None)
@ -265,6 +300,7 @@ class TestBuildHeader(unittest.TestCase):
self.assertEqual(header, 'Title: test\n' + 'Attachments: output/test1, '
+ 'output/test2\n\n')
@unittest.skipUnless(BeautifulSoup, 'Needs BeautifulSoup module')
class TestWordpressXMLAttachements(unittest.TestCase):
def setUp(self):