A script to analyze the stop locations.
[ottawa-travel-planner.git] / tests / test_busstopmash_regexes.py
blobcb0c06cedf1fe9c57c2b8498f89d2dccc50c815e
1 # vi: set fileencoding=latin1 softtabstop=4 shiftwidth=4 tabstop=8 expandtab:
3 # The above line tells Python to use Latin-1, which seems to be right for the
4 # accented characters coming back from the travel planner.
6 import unittest
7 import BusStopMashup
9 class TestStopRegex(unittest.TestCase):
10 def testAccentedEInName(self):
11 text = r"""<span><strong><b>613-560-1000 plus <a href='iframe.asp?route=busstop&INFO_PHONE=3035' target='iframe'>3035</a></b></strong><small> (RA970)</small><br>HERON STOP / ARRÊT 4A <br><a href='iframe.asp?route=4&dir=10' target='iframe'>4</a> <a href='iframe.asp?route=87&dir=11' target='iframe'>87</a> <a href='iframe.asp?route=107&dir=11' target='iframe'>107</a> <a href='iframe.asp?route=111&dir=10' target='iframe'>111</a> <a href='iframe.asp?route=118&dir=10' target='iframe'>118</a> <a href='iframe.asp?route=140&dir=11' target='iframe'>140</a> <a href='iframe.asp?route=656&dir=11' target='iframe'>656</a> </span>"""
12 match = BusStopMashup._stop_rx.search(text)
13 self.assertNotEquals(match, None)
14 self.assertEquals(match.group("stopnum"), "3035")
15 self.assertEquals(match.group("code"), "RA970")
17 def testLongStopCode(self):
18 text = r"""<span><strong><b>613-560-1000 plus <a href='iframe.asp?route=busstop&INFO_PHONE=3035' target='iframe'>3035</a></b></strong><small> (SCO018)</small><br>HERON SCOTIABANK 2A<br></span>"""
19 match = BusStopMashup._stop_rx.search(text)
20 self.assertNotEquals(match, None)
21 self.assertEquals(match.group("code"), "SCO018")
23 if __name__ == '__main__':
24 unittest.main()