From 4c763dc8327aec9859a7fc57220c14910ae84128 Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Sun, 5 Feb 2017 22:46:43 +0100 Subject: [PATCH] Added more tests Signed-off-by: Lars Kiesow --- tests/test_entry.py | 15 +++++++++++++++ tests/test_extension.py | 27 +++++++++++++++++++++++++++ tests/test_feed.py | 3 +++ 3 files changed, 45 insertions(+) diff --git a/tests/test_entry.py b/tests/test_entry.py index ead38ff..2b986cf 100644 --- a/tests/test_entry.py +++ b/tests/test_entry.py @@ -40,6 +40,21 @@ class TestSequenceFunctions(unittest.TestCase): self.fg = fg + def test_setEntries(self): + fg2 = FeedGenerator() + fg2.entry(self.fg.entry()) + assert len(fg2.entry()) == 3 + assert self.fg.entry() == fg2.entry() + + def test_loadExtension(self): + fe = self.fg.add_item() + fe.id('1') + fe.title(u'…') + fe.content(u'…') + fe.load_extension('base') + assert fe.base + assert self.fg.atom_str() + def test_checkEntryNumbers(self): fg = self.fg assert len(fg.entry()) == 3 diff --git a/tests/test_extension.py b/tests/test_extension.py index 5499387..c1506a9 100644 --- a/tests/test_extension.py +++ b/tests/test_extension.py @@ -82,6 +82,29 @@ class TestExtensionPodcast(unittest.TestCase): assert cat[0] == 'Technology' assert scat[0] == 'Podcasting' + def test_podcastItems(self): + fg = self.fg + fg.podcast.itunes_author('Lars Kiesow') + fg.podcast.itunes_block('x') + fg.podcast.itunes_complete(False) + fg.podcast.itunes_explicit('no') + fg.podcast.itunes_image('x.png') + fg.podcast.itunes_subtitle('x') + fg.podcast.itunes_summary('x') + assert fg.podcast.itunes_author() == 'Lars Kiesow' + assert fg.podcast.itunes_block() == 'x' + assert fg.podcast.itunes_complete() == 'no' + assert fg.podcast.itunes_explicit() == 'no' + assert fg.podcast.itunes_image() == 'x.png' + assert fg.podcast.itunes_subtitle() == 'x' + assert fg.podcast.itunes_summary() == 'x' + + # Check that we have the item in the resulting XML + ns = {'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'} + root = etree.fromstring(self.fg.rss_str()) + author = root.xpath('/rss/channel/itunes:author/text()', namespaces=ns) + assert author == ['Lars Kiesow'] + def test_podcastEntryItems(self): fe = self.fg.add_item() fe.title('y') @@ -134,3 +157,7 @@ class TestExtensionDc(unittest.TestCase): m = getattr(self.fg.dc, method) m(method) assert m() == [method] + + self.fg.id('123') + assert self.fg.atom_str() + assert self.fg.rss_str() diff --git a/tests/test_feed.py b/tests/test_feed.py index cc4a188..853a724 100644 --- a/tests/test_feed.py +++ b/tests/test_feed.py @@ -100,6 +100,9 @@ class TestSequenceFunctions(unittest.TestCase): name=self.textInputName, link=self.textInputLink) fg.ttl(self.ttl) fg.webMaster(self.webMaster) + fg.updated('2017-02-05 13:26:58+01:00') + fg.pubDate('2017-02-05 13:26:58+01:00') + fg.generator('python-feedgen', 'x', uri='http://github.com/lkie...') self.fg = fg