Skip to content

Commit

Permalink
Merge pull request #1623 from avaris/fix_test_importer
Browse files Browse the repository at this point in the history
Fix for tests that were broken in #1607
  • Loading branch information
justinmayer committed Feb 11, 2015
2 parents 8218923 + 7fc6aab commit efc5e6f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pelican/tests/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re

import locale
from codecs import open
from pelican.tools.pelican_import import wp2fields, fields2pelican, decode_wp_content, build_header, build_markdown_header, get_attachments, download_attachments
from pelican.tests.support import (unittest, temporary_folder, mute,
skipIfNoExecutable)
Expand Down Expand Up @@ -41,15 +42,15 @@ def tearDown(self):

def test_ignore_empty_posts(self):
self.assertTrue(self.posts)
for title, content, fname, date, author, categ, tags, kind, format in self.posts:
for title, content, fname, date, author, categ, tags, status, 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:
for title, content, fname, date, author, categ, tags, status, kind, format in self.posts:
if kind == 'page':
pages_data.append((title, fname))
self.assertEqual(2, len(pages_data))
Expand Down Expand Up @@ -85,7 +86,7 @@ def test_dircat(self):
def test_unless_custom_post_all_items_should_be_pages_or_posts(self):
self.assertTrue(self.posts)
pages_data = []
for title, content, fname, date, author, categ, tags, kind, format in self.posts:
for title, content, fname, date, author, categ, tags, status, kind, format in self.posts:
if kind == 'page' or kind == 'article':
pass
else:
Expand All @@ -95,7 +96,7 @@ def test_unless_custom_post_all_items_should_be_pages_or_posts(self):
def test_recognise_custom_post_type(self):
self.assertTrue(self.custposts)
cust_data = []
for title, content, fname, date, author, categ, tags, kind, format in self.custposts:
for title, content, fname, date, author, categ, tags, status, kind, format in self.custposts:
if kind == 'article' or kind == 'page':
pass
else:
Expand All @@ -110,7 +111,7 @@ def test_custom_posts_put_in_own_dir(self):
test_posts = []
for post in self.custposts:
# check post kind
if post[7] == 'article' or post[7] == 'page':
if post[8] == 'article' or post[8] == 'page':
pass
else:
test_posts.append(post)
Expand All @@ -119,7 +120,7 @@ def test_custom_posts_put_in_own_dir(self):
index = 0
for post in test_posts:
name = post[2]
kind = post[7]
kind = post[8]
name += '.md'
filename = os.path.join(kind, name)
out_name = fnames[index]
Expand All @@ -131,7 +132,7 @@ def test_custom_posts_put_in_own_dir_and_catagory_sub_dir(self):
test_posts = []
for post in self.custposts:
# check post kind
if post[7] == 'article' or post[7] == 'page':
if post[8] == 'article' or post[8] == 'page':
pass
else:
test_posts.append(post)
Expand All @@ -141,7 +142,7 @@ def test_custom_posts_put_in_own_dir_and_catagory_sub_dir(self):
index = 0
for post in test_posts:
name = post[2]
kind = post[7]
kind = post[8]
category = slugify(post[5][0])
name += '.md'
filename = os.path.join(kind, category, name)
Expand All @@ -155,7 +156,7 @@ def test_wp_custpost_true_dirpage_false(self):
test_posts = []
for post in self.custposts:
# check post kind
if post[7] == 'page':
if post[8] == 'page':
test_posts.append(post)
with temporary_folder() as temp:
fnames = list(silent_f2p(test_posts, 'markdown', temp,
Expand All @@ -171,7 +172,7 @@ def test_wp_custpost_true_dirpage_false(self):

def test_can_toggle_raw_html_code_parsing(self):
def r(f):
with open(f) as infile:
with open(f, encoding='utf-8') as infile:
return infile.read()
silent_f2p = mute(True)(fields2pelican)

Expand Down Expand Up @@ -213,7 +214,7 @@ def test_decode_wp_content(self):

def test_preserve_verbatim_formatting(self):
def r(f):
with open(f) as infile:
with open(f, encoding='utf-8') as infile:
return infile.read()
silent_f2p = mute(True)(fields2pelican)
test_post = filter(lambda p: p[0].startswith("Code in List"), self.posts)
Expand All @@ -228,7 +229,7 @@ def r(f):

def test_code_in_list(self):
def r(f):
with open(f) as infile:
with open(f, encoding='utf-8') as infile:
return infile.read()
silent_f2p = mute(True)(fields2pelican)
test_post = filter(lambda p: p[0].startswith("Code in List"), self.posts)
Expand Down

0 comments on commit efc5e6f

Please sign in to comment.