forked from github/pelican
update the readers tests
This commit is contained in:
parent
2be674c909
commit
73b37989f7
1 changed files with 18 additions and 23 deletions
|
|
@ -14,17 +14,6 @@ CONTENT_PATH = os.path.join(CUR_DIR, 'content')
|
|||
def _path(*args):
|
||||
return os.path.join(CONTENT_PATH, *args)
|
||||
|
||||
class ReaderTests(unittest.TestCase):
|
||||
def test_readfile_unknown_extension(self):
|
||||
f = _path('article_with_metadata.unknownextension')
|
||||
with self.assertRaises(TypeError) as cm:
|
||||
readers.read_file(f)
|
||||
ex = cm.exception
|
||||
self.assertEqual('Pelican does not know how to parse ' + f, ex.message)
|
||||
#, setattr, root.c1.c2, 'text', "test")
|
||||
# self.assertTrue(1 == 0)
|
||||
# except TypeError:
|
||||
# self.assertTrue(1 == 1)
|
||||
|
||||
class ReaderTest(unittest.TestCase):
|
||||
|
||||
|
|
@ -34,6 +23,15 @@ class ReaderTest(unittest.TestCase):
|
|||
return r.read_file(base_path=CONTENT_PATH, path=path)
|
||||
|
||||
|
||||
class DefaultReaderTest(ReaderTest):
|
||||
|
||||
def test_readfile_unknown_extension(self):
|
||||
with self.assertRaises(TypeError) as cm:
|
||||
self.read_file(path='article_with_metadata.unknownextension')
|
||||
ex = cm.exception
|
||||
self.assertIn('Pelican does not know how to parse', ex.message)
|
||||
|
||||
|
||||
class RstReaderTest(ReaderTest):
|
||||
|
||||
def test_article_with_metadata(self):
|
||||
|
|
@ -98,11 +96,11 @@ class RstReaderTest(ReaderTest):
|
|||
# Keys of metadata should be lowercase.
|
||||
reader = readers.RstReader(settings=get_settings())
|
||||
content, metadata = reader.read(
|
||||
_path('article_with_uppercase_metadata.rst'))
|
||||
_path('article_with_uppercase_metadata.rst'))
|
||||
|
||||
self.assertIn('category', metadata, 'Key should be lowercase.')
|
||||
self.assertEqual('Yeah', metadata.get('category'),
|
||||
'Value keeps case.')
|
||||
'Value keeps case.')
|
||||
|
||||
def test_typogrify(self):
|
||||
# if nothing is specified in the settings, the content should be
|
||||
|
|
@ -158,7 +156,6 @@ class MdReaderTest(ReaderTest):
|
|||
for key, value in metadata.items():
|
||||
self.assertEqual(value, expected[key], key)
|
||||
|
||||
|
||||
@unittest.skipUnless(readers.Markdown, "markdown isn't installed")
|
||||
def test_article_with_footnote(self):
|
||||
reader = readers.MarkdownReader(settings=get_settings())
|
||||
|
|
@ -179,8 +176,8 @@ class MdReaderTest(ReaderTest):
|
|||
'title="Jump back to footnote 1 in the text">↩</a></p>\n'
|
||||
'</li>\n<li id="fn:footnote">\n'
|
||||
'<p>Named footnote '
|
||||
'<a class="footnote-backref" href="#fnref:footnote" rev="footnote" '
|
||||
'title="Jump back to footnote 2 in the text">↩</a></p>\n'
|
||||
'<a class="footnote-backref" href="#fnref:footnote" rev="footnote"'
|
||||
' title="Jump back to footnote 2 in the text">↩</a></p>\n'
|
||||
'</li>\n</ol>\n</div>')
|
||||
expected_metadata = {
|
||||
'title': 'Article with markdown containing footnotes',
|
||||
|
|
@ -194,7 +191,6 @@ class MdReaderTest(ReaderTest):
|
|||
for key, value in metadata.items():
|
||||
self.assertEqual(value, expected_metadata[key], key)
|
||||
|
||||
|
||||
@unittest.skipUnless(readers.Markdown, "markdown isn't installed")
|
||||
def test_article_with_file_extensions(self):
|
||||
reader = readers.MarkdownReader(settings=get_settings())
|
||||
|
|
@ -203,9 +199,9 @@ class MdReaderTest(ReaderTest):
|
|||
content, metadata = reader.read(
|
||||
_path('article_with_md_extension.md'))
|
||||
expected = (
|
||||
"<h1>Test Markdown File Header</h1>\n"
|
||||
"<h2>Used for pelican test</h2>\n"
|
||||
"<p>The quick brown fox jumped over the lazy dog's back.</p>")
|
||||
"<h1>Test Markdown File Header</h1>\n"
|
||||
"<h2>Used for pelican test</h2>\n"
|
||||
"<p>The quick brown fox jumped over the lazy dog's back.</p>")
|
||||
self.assertEqual(content, expected)
|
||||
# test to ensure the mkd file extension is being processed by the
|
||||
# correct reader
|
||||
|
|
@ -319,7 +315,7 @@ class AdReaderTest(ReaderTest):
|
|||
def test_article_with_asc_options(self):
|
||||
# test to ensure the ASCIIDOC_OPTIONS is being used
|
||||
reader = readers.AsciiDocReader(
|
||||
dict(ASCIIDOC_OPTIONS=["-a revision=1.0.42"]))
|
||||
dict(ASCIIDOC_OPTIONS=["-a revision=1.0.42"]))
|
||||
content, metadata = reader.read(_path('article_with_asc_options.asc'))
|
||||
expected = ('<hr>\n<h2><a name="_used_for_pelican_test"></a>Used for'
|
||||
' pelican test</h2>\n<p>version 1.0.42</p>\n'
|
||||
|
|
@ -375,7 +371,6 @@ class HTMLReaderTest(ReaderTest):
|
|||
for key, value in expected.items():
|
||||
self.assertEqual(value, page.metadata[key], key)
|
||||
|
||||
|
||||
def test_article_with_null_attributes(self):
|
||||
page = self.read_file(path='article_with_null_attributes.html')
|
||||
|
||||
|
|
@ -389,4 +384,4 @@ class HTMLReaderTest(ReaderTest):
|
|||
page = self.read_file(path='article_with_uppercase_metadata.html')
|
||||
self.assertIn('category', page.metadata, 'Key should be lowercase.')
|
||||
self.assertEqual('Yeah', page.metadata.get('category'),
|
||||
'Value keeps cases.')
|
||||
'Value keeps cases.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue