From b8db970455100b3b9393fcb20cc1b7fd9c3730f4 Mon Sep 17 00:00:00 2001 From: Ondrej Grover Date: Sun, 25 May 2014 09:12:35 +0200 Subject: [PATCH] Fix RstReader authors metadata processing The reader would return a list of authors already, but METADATA_PROCESSORS['authors'] expects a string. Added a test case for this (only the HTMLReader had it). --- pelican/readers.py | 1 + pelican/tests/test_generators.py | 1 + pelican/tests/test_readers.py | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/pelican/readers.py b/pelican/readers.py index c63b8981..60df8551 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -145,6 +145,7 @@ class RstReader(BaseReader): elif element.tagname == 'authors': # author list name = element.tagname value = [element.astext() for element in element.children] + value = ','.join(value) # METADATA_PROCESSORS expects a string else: # standard fields (e.g. address) name = element.tagname value = element.astext() diff --git a/pelican/tests/test_generators.py b/pelican/tests/test_generators.py index 7b79e8f3..156f7b50 100644 --- a/pelican/tests/test_generators.py +++ b/pelican/tests/test_generators.py @@ -109,6 +109,7 @@ class TestArticlesGenerator(unittest.TestCase): ['This is an article with category !', 'published', 'yeah', 'article'], ['This is an article with multiple authors!', 'published', 'Default', 'article'], + ['This is an article with multiple authors!', 'published', 'Default', 'article'], ['This is an article without category !', 'published', 'Default', 'article'], ['This is an article without category !', 'published', diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py index fd30e9b9..3533cd31 100644 --- a/pelican/tests/test_readers.py +++ b/pelican/tests/test_readers.py @@ -150,6 +150,15 @@ class RstReaderTest(ReaderTest): except ImportError: return unittest.skip('need the typogrify distribution') + def test_article_with_multiple_authors(self): + page = self.read_file(path='article_with_multiple_authors.rst') + expected = { + 'authors': ['First Author', 'Second Author'] + } + + for key, value in expected.items(): + self.assertEqual(value, page.metadata[key], key) + class MdReaderTest(ReaderTest):