From da06835e8bd99a9c996719ad47efcf23b9b7e0e6 Mon Sep 17 00:00:00 2001 From: snipem Date: Mon, 2 Jun 2014 22:45:15 +0200 Subject: [PATCH] Added unit test cases for extension loading Also fixed bugs regarding the upcoming feed.py fix --- .gitignore | 4 ++++ feedgen/tests/__init__.py | 0 feedgen/tests/test_entry.py | 7 +++---- feedgen/tests/test_extension.py | 0 feedgen/tests/test_feed.py | 23 +++++++++++++++++------ 5 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 feedgen/tests/__init__.py create mode 100644 feedgen/tests/test_extension.py diff --git a/.gitignore b/.gitignore index acc4484..b6f6775 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ venv feedgen/tests/tmp_Atomfeed.xml feedgen/tests/tmp_Rssfeed.xml + +tmp_Atomfeed.xml + +tmp_Rssfeed.xml diff --git a/feedgen/tests/__init__.py b/feedgen/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/feedgen/tests/test_entry.py b/feedgen/tests/test_entry.py index 38023d3..19186a5 100644 --- a/feedgen/tests/test_entry.py +++ b/feedgen/tests/test_entry.py @@ -1,15 +1,14 @@ # -*- coding: utf-8 -*- """ -Tests for a basic feed +Tests for a basic entry -These test cases contain test cases for a basic feed. A basic feed does not contain entries so far. +These test cases contain test cases for a basic entry. """ import unittest from lxml import etree -from feedgen.feed import FeedGenerator - +from ..feed import FeedGenerator class TestSequenceFunctions(unittest.TestCase): diff --git a/feedgen/tests/test_extension.py b/feedgen/tests/test_extension.py new file mode 100644 index 0000000..e69de29 diff --git a/feedgen/tests/test_feed.py b/feedgen/tests/test_feed.py index 12b51ee..79f144b 100644 --- a/feedgen/tests/test_feed.py +++ b/feedgen/tests/test_feed.py @@ -8,11 +8,12 @@ These test cases contain test cases for a basic feed. A basic feed does not cont import unittest from lxml import etree +from ..feed import FeedGenerator class TestSequenceFunctions(unittest.TestCase): def setUp(self): - from feedgen.feed import FeedGenerator + fg = FeedGenerator() self.nsAtom = "http://www.w3.org/2005/Atom" @@ -164,12 +165,16 @@ class TestSequenceFunctions(unittest.TestCase): def test_rssFeedString(self): fg = self.fg - rssString = fg.rss_str(pretty=True) self.checkRssString(rssString) - def test_loadExtension(self): - raise Exception('Not yet implemented') + def test_loadPodcastExtension(self): + fg = self.fg + fg.load_extension('podcast', atom=True, rss=True) + + def test_loadDcExtension(self): + fg = self.fg + fg.load_extension('dc', atom=True, rss=True) def checkRssString(self, rssString): @@ -177,6 +182,8 @@ class TestSequenceFunctions(unittest.TestCase): nsAtom = self.nsAtom nsRss = self.nsRss + print (rssString) + channel = feed.find("channel") assert channel != None @@ -191,7 +198,11 @@ class TestSequenceFunctions(unittest.TestCase): assert channel.find("image").find("title").text == self.title assert channel.find("image").find("link").text == self.link2Href assert channel.find("category").text == self.categoryLabel - assert channel.find("cloud").text == self.cloud + assert channel.find("cloud").get('domain') == self.cloudDomain + assert channel.find("cloud").get('port') == self.cloudPort + assert channel.find("cloud").get('path') == self.cloudPath + assert channel.find("cloud").get('registerProcedure') == self.cloudRegisterProcedure + assert channel.find("cloud").get('protocol') == self.cloudProtocol assert channel.find("copyright").text == self.copyright assert channel.find("docs").text == self.docs assert channel.find("managingEditor").text == self.managingEditor @@ -202,7 +213,7 @@ class TestSequenceFunctions(unittest.TestCase): assert channel.find("textInput").get('description') == self.textInputDescription assert channel.find("textInput").get('name') == self.textInputName assert channel.find("textInput").get('link') == self.textInputLink - assert channel.find("ttl").text == self.ttl + assert int(channel.find("ttl").text) == self.ttl assert channel.find("webMaster").text == self.webMaster if __name__ == '__main__':