Added unit test cases for extension loading

Also fixed bugs regarding the upcoming feed.py fix
This commit is contained in:
snipem 2014-06-02 22:45:15 +02:00
parent d2bbc87f6c
commit da06835e8b
5 changed files with 24 additions and 10 deletions

4
.gitignore vendored
View file

@ -6,3 +6,7 @@ venv
feedgen/tests/tmp_Atomfeed.xml feedgen/tests/tmp_Atomfeed.xml
feedgen/tests/tmp_Rssfeed.xml feedgen/tests/tmp_Rssfeed.xml
tmp_Atomfeed.xml
tmp_Rssfeed.xml

View file

View file

@ -1,15 +1,14 @@
# -*- coding: utf-8 -*- # -*- 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 import unittest
from lxml import etree from lxml import etree
from feedgen.feed import FeedGenerator from ..feed import FeedGenerator
class TestSequenceFunctions(unittest.TestCase): class TestSequenceFunctions(unittest.TestCase):

View file

View file

@ -8,11 +8,12 @@ These test cases contain test cases for a basic feed. A basic feed does not cont
import unittest import unittest
from lxml import etree from lxml import etree
from ..feed import FeedGenerator
class TestSequenceFunctions(unittest.TestCase): class TestSequenceFunctions(unittest.TestCase):
def setUp(self): def setUp(self):
from feedgen.feed import FeedGenerator
fg = FeedGenerator() fg = FeedGenerator()
self.nsAtom = "http://www.w3.org/2005/Atom" self.nsAtom = "http://www.w3.org/2005/Atom"
@ -164,12 +165,16 @@ class TestSequenceFunctions(unittest.TestCase):
def test_rssFeedString(self): def test_rssFeedString(self):
fg = self.fg fg = self.fg
rssString = fg.rss_str(pretty=True) rssString = fg.rss_str(pretty=True)
self.checkRssString(rssString) self.checkRssString(rssString)
def test_loadExtension(self): def test_loadPodcastExtension(self):
raise Exception('Not yet implemented') 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): def checkRssString(self, rssString):
@ -177,6 +182,8 @@ class TestSequenceFunctions(unittest.TestCase):
nsAtom = self.nsAtom nsAtom = self.nsAtom
nsRss = self.nsRss nsRss = self.nsRss
print (rssString)
channel = feed.find("channel") channel = feed.find("channel")
assert channel != None 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("title").text == self.title
assert channel.find("image").find("link").text == self.link2Href assert channel.find("image").find("link").text == self.link2Href
assert channel.find("category").text == self.categoryLabel 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("copyright").text == self.copyright
assert channel.find("docs").text == self.docs assert channel.find("docs").text == self.docs
assert channel.find("managingEditor").text == self.managingEditor 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('description') == self.textInputDescription
assert channel.find("textInput").get('name') == self.textInputName assert channel.find("textInput").get('name') == self.textInputName
assert channel.find("textInput").get('link') == self.textInputLink 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 assert channel.find("webMaster").text == self.webMaster
if __name__ == '__main__': if __name__ == '__main__':