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