fix proxy change detection
[straw.git] / test / TestUtils.py
blob2193b85b0d193b8e086f77a4eda373626a9a773a
1 import sys
2 import unittest
3 sys.path.insert(0, '../src/lib')
4 import utils
6 class UtilsTestCase(unittest.TestCase):
8 def testFormatDateBadEncoding(self):
9 # Bugzilla 145513
10 encoding = "en_US.ISO8859-1"
11 format = "%A"
12 time = (2004, 8, 5, 20, 29, 59, 3, 218, 0)
13 try:
14 utils.format_date(time, format, encoding)
15 except Exception, ex:
16 self.fail("format_date: %s" % str(ex))
18 def testURLlocation(self):
19 url = "http://www.amazon.com/gp/aws/sdk/103-9053546-3314261"
20 self.assertEqual("http://www.amazon.com", utils.get_url_location(url))
22 def testReadText(self):
23 text = "Blah &gt;foo&lt; <p>bar</p>"
24 t = utils.read_text(text, 60)
25 self.assertEqual(t, "Blah >foo< bar")
27 def testCompleteUrl(self):
28 tlist = [("images/foo.jpg","http://blah.com","http://blah.com/images/foo.jpg"),
29 ("/images/foo.jpg","http://b.com","http://b.com/images/foo.jpg")]
30 for u,b,r in tlist:
31 self.assertEqual(r,utils.complete_url(u,b))
33 def suite():
34 suite = unittest.makeSuite(UtilsTestCase, 'test')
35 return suite
37 if __name__ == '__main__':
38 unittest.main()