forked from github/pelican
Import wordpress pages to pages/ subdir with --dir-page option
When importing from Wordpress, the --dir-page directive (disabled by default) automatically adds files to the pages/ when they are recognised as pages, as opposed to posts.
This commit is contained in:
parent
870ec0efe8
commit
8c7ea8df98
3 changed files with 54 additions and 9 deletions
|
|
@ -32,9 +32,28 @@ class TestWordpressXmlImporter(unittest.TestCase):
|
|||
|
||||
def test_ignore_empty_posts(self):
|
||||
self.assertTrue(self.posts)
|
||||
for title, content, fname, date, author, categ, tags, format in self.posts:
|
||||
for title, content, fname, date, author, categ, tags, kind, format in self.posts:
|
||||
self.assertTrue(title.strip())
|
||||
|
||||
def test_recognise_page_kind(self):
|
||||
""" Check that we recognise pages in wordpress, as opposed to posts """
|
||||
self.assertTrue(self.posts)
|
||||
# Collect (title, filename, kind) of non-empty posts recognised as page
|
||||
pages_data = []
|
||||
for title, content, fname, date, author, categ, tags, kind, format in self.posts:
|
||||
if kind == 'page':
|
||||
pages_data.append((title, fname))
|
||||
self.assertEqual(2, len(pages_data))
|
||||
self.assertEqual(('Page', 'contact'), pages_data[0])
|
||||
self.assertEqual(('Empty Page', 'empty'), pages_data[1])
|
||||
|
||||
def test_dirpage_directive_for_page_kind(self):
|
||||
silent_f2p = mute(True)(fields2pelican)
|
||||
test_post = filter(lambda p: p[0].startswith("Empty Page"), self.posts)
|
||||
with temporary_folder() as temp:
|
||||
fname = list(silent_f2p(test_post, 'markdown', temp, dirpage=True))[0]
|
||||
self.assertTrue(fname.endswith('pages%sempty.md' % os.path.sep))
|
||||
|
||||
def test_can_toggle_raw_html_code_parsing(self):
|
||||
def r(f):
|
||||
with open(f) as infile:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue