Map space bar to scroll_unread_items (thanks estar).
[straw.git] / test / TestSubscribe.py
blobc30b30d7b0ad3f6381aaaca6063d269b8cbd1102
1 import unittest
2 import os
3 import sys
5 try:
6 import pmock
7 except ImportError:
8 sys.exit("You need python-mock (pmock, 0.3) to run this test. http://pmock.sf.net")
10 sys.path.insert(0, '../src/lib')
11 import subscribe
13 class FeedLocationPresenterTestCase(unittest.TestCase):
14 def setUp(self):
15 self.presenter = subscribe.FeedLocationPresenter()
17 def testSplit_urlWithAbsoluteUrl(self):
18 feed = "http://www.unpluggable.com/plans/log.rdf"
19 url, username, password = self.presenter.split_url(feed)
20 self.assertEqual(url, feed)
22 def testSplit_urlWithAuthToken(self):
23 feed = "http://foo:com@test.org/very/long/path/to/feed.xml"
24 url, username, password = self.presenter.split_url(feed)
25 self.assertEqual(url, "http://test.org/very/long/path/to/feed.xml")
26 self.assertEqual("foo", username)
27 self.assertEqual("com", password)
29 def testUrlWithLeadingSpace(self):
30 feed = " http://www.test.org/rss10.xml "
31 url, username, password = self.presenter.split_url(feed)
32 self.assertEqual("http://www.test.org/rss10.xml", url)
34 def testUrlSchemeNotHttp(self):
35 feed = "file:///home/bart/simpson.xml"
36 view = pmock.Mock()
37 model = pmock.Mock()
38 view.expects(pmock.at_least_once()).method("report_error")
39 model.expects(pmock.at_least_once()).method("poll")
40 self.presenter.view = view
41 self.presenter.model = model
42 url, uname, pword = self.presenter.split_url(feed)
43 self.presenter.find_feed(url)
44 try:
45 view.verify()
46 except Exception, ex:
47 # view.report_error() should've been called since
48 # 'file' is not currently supported
49 self.fail(ex)
51 def testDomainCheck(self):
52 feed = "http://www.foo.org/blog/devel/atom.xml"
53 self.presenter.split_url(feed)
54 self.assertEqual("www.foo.org", self.presenter.get_feed_domain())
56 def tearDown(self):
57 self.presenter = None
59 if __name__ == '__main__':
60 suite = unittest.TestSuite()
61 suite.addTest(unittest.makeSuite(FeedLocationPresenterTestCase, 'test'))
62 #suite.addTest(unittest.makeSuite(FeedsPresenterTestCase, 'test'))
63 unittest.TextTestRunner(verbosity=2).run(suite)