Script to grab stop codes from allstops.xml and sort
[ottawa-travel-planner.git] / tests / test_planner_regexes.py
bloba3dfc0c62492cf2b630613c212ec61e9623e177d
2 # vi: set softtabstop=4 shiftwidth=4 tabstop=8 expandtab:
4 import unittest
5 import Planner
8 class TestErrorRegex(unittest.TestCase):
10 def testBadFromAddress(self):
11 text = """
12 <html>blabbity blah
14 <table cellpadding="0" cellspacing="0" summary="Warning message" class="warning" width="85%">
15 <tr>
16 <td><img src="tripPlanning/images/imgWarning.gif"></td>
17 <td>The address you specified was not found. Please enter another.</td>
18 </tr>
19 </table></html>"""
20 match = Planner._error_rx.search(text)
21 self.assertNotEquals(match, None)
22 self.assertEquals(match.group("msg"),
23 ("The address you specified was not found. "
24 "Please enter another."))
26 # I don't know if it ever spits out multi-line errors, but might as well
27 # check it.
28 def testMultiLineWarning(self):
29 text = """
30 <html>blabbity blah
32 <table class="warning" width="85%">
33 <tr>
34 <td>The address you specified was not found.""" "\n" \
35 """Please enter another.</td>
36 </tr>
37 </table></html>"""
39 match = Planner._error_rx.search(text)
40 self.assertNotEquals(match, None)
41 self.assertEquals(match.group("msg"),
42 ("The address you specified was not found.\n"
43 "Please enter another."))
45 # This one has a lot of whitespace that we should cut.
46 def testNoItinerariesError(self):
47 text = """
48 <table cellpadding="0" cellspacing="0" summary="Warning message" class="warning" width="85%">
49 <tr>
50 <td><img src="tripPlanning/images/imgWarning.gif"></td>
51 <td>
55 No itineraries could be found.
58 </td>
59 </tr>
60 </table>"""
61 match = Planner._error_rx.search(text)
62 self.assertNotEquals(match, None)
63 self.assertEquals(match.group("msg"), "No itineraries could be found.")
66 if __name__ == '__main__':
67 unittest.main()