mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Added strip raw option to wordpress xml importer
This commit is contained in:
parent
1779b66f10
commit
ba8ed9fb18
4 changed files with 728 additions and 8 deletions
43
tests/test_importer.py
Normal file
43
tests/test_importer.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
from pelican.tools.pelican_import import wp2fields, fields2pelican
|
||||
from .support import unittest, temporary_folder, mute
|
||||
|
||||
CUR_DIR = os.path.dirname(__file__)
|
||||
WORDPRESS_XML_SAMPLE = os.path.join(CUR_DIR, 'content', 'wordpressexport.xml')
|
||||
|
||||
|
||||
class TestWordpressXmlImporter(unittest.TestCase):
|
||||
|
||||
|
||||
def setUp(self):
|
||||
self.posts = wp2fields(WORDPRESS_XML_SAMPLE)
|
||||
|
||||
|
||||
def test_ignore_empty_posts(self):
|
||||
|
||||
posts = list(self.posts)
|
||||
self.assertTrue(posts)
|
||||
for title, content, fname, date, author, categ, tags, format in posts:
|
||||
self.assertTrue(title.strip())
|
||||
|
||||
|
||||
def test_can_toggle_raw_html_code_parsing(self):
|
||||
|
||||
posts = list(self.posts)
|
||||
r = lambda f: open(f).read()
|
||||
silent_f2p = mute(True)(fields2pelican)
|
||||
|
||||
with temporary_folder() as temp:
|
||||
|
||||
rst_files = (r(f) for f in silent_f2p(posts, 'markdown', temp))
|
||||
self.assertTrue(any('<iframe' in rst for rst in rst_files))
|
||||
rst_files = (r(f) for f in silent_f2p(posts, 'markdown', temp, strip_raw=True))
|
||||
self.assertFalse(any('<iframe' in rst for rst in rst_files))
|
||||
# no effect in rst
|
||||
rst_files = (r(f) for f in silent_f2p(posts, 'rst', temp))
|
||||
self.assertFalse(any('<iframe' in rst for rst in rst_files))
|
||||
rst_files = (r(f) for f in silent_f2p(posts, 'rst', temp, strip_raw=True))
|
||||
self.assertFalse(any('<iframe' in rst for rst in rst_files))
|
||||
Loading…
Add table
Add a link
Reference in a new issue