diff tests/FeedUpdaterTests.py @ 9:fd4c8bfa62d6

FeedUpdater throws an exception if the URL could not be retrieved successfully. Includes unit tests.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 27 Apr 2010 10:22:35 +0200
parents
children bb3c851b18b1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/FeedUpdaterTests.py	Tue Apr 27 10:22:35 2010 +0200
@@ -0,0 +1,24 @@
+
+import unittest
+from Feed import Feed
+from FeedUpdater import FeedUpdater
+from FeedUpdater import FeedUpdateException
+
+class FeedUpdaterTests(unittest.TestCase):
+    def testFeedContainsInvalidUrl(self):
+        feed = Feed("invalid", "http://thisurldoesnotexist.xxx")
+        try:
+            FeedUpdater(None, feed).update()
+            self.fail("updating an invalid URL must fail")
+        except FeedUpdateException:
+            # this one was expected
+            pass
+        
+    def testFeedContainsValidUrl(self):
+        feed = Feed("valid", "http://www.joelonsoftware.com/rss.xml")
+        result = FeedUpdater(None, feed).getFeed()
+        self.assertEqual("Joel on Software", result["feed"].title)
+
+if __name__ == "__main__":
+    #import sys;sys.argv = ['', 'Test.testName']
+    unittest.main()
\ No newline at end of file