Show next bus/tram/underground departures.
This program ist unofficial.
+
+Running unit tests:
+
+$ python -m gotovienna.tests.runner
+
--- /dev/null
+import unittest
+import sys
+import os
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
+
+from gotovienna.realtime import *
+
+parser = ITipParser()
+
+class ParseTest(unittest.TestCase):
+
+ def test_lines(self):
+ lines = parser.lines
+ self.assertTrue(type(lines) == dict)
+ self.assertTrue(lines)
+
+ def test_stations(self):
+ lines = parser.lines
+
+ s = []
+ for line in lines:
+ s.append(parser.get_stations(line[0]))
+ self.assertTrue(s)
+
+if __name__ == '__main__':
+ unittest.main()
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import unittest
+from datetime import datetime
+
+from gotovienna.routing import *
+
+dtime = datetime.now()
+dtime = dtime.replace(hour=15, minute=0)
+
+origin = u'Börse'.encode('UTF-8')
+destination = 'Handelskai'
+s = search((origin, 'stop'), (destination, 'stop'), dtime).read()
+parser = sParser(s)
+p = rParser(s)
+
+
+originc = 'Simmeri'
+destinationc = 'Karlspla'
+sc = search((originc, 'stop'), (destinationc, 'stop'), dtime).read()
+parserc = sParser(sc)
+
+
+origina = 'Zwicklgasse 1'
+destinationa = 'Himmelstrasse 1'
+ot = dt = 'address'
+
+
+originac = 'Foobar Strasse 123'
+destinationac = 'Bazgasse 321'
+
+
+class SearchTest(unittest.TestCase):
+
+ def test_state(self):
+ state = parser.check_page()
+ statec = parserc.check_page()
+
+ self.assertEqual(PageType.RESULT, state)
+ self.assertEqual(PageType.CORRECTION, statec)
+
+ def test_correction(self):
+ cor = parserc.get_correction()
+ s = search((cor[0][0], 'stop'), (cor[1][0], 'stop'), dtime).read()
+ parser = sParser(s)
+ self.assertEqual(PageType.RESULT, parser.check_page())
+
+ def test_overview_shouldFindMultipleItems(self):
+ # TODO Replace with assertGreater in new python version
+ self.assertTrue(len(p.overview) > 1)
+
+ def test_detail_shouldFindMultipleItems(self):
+ # TODO Replace with assertGreater in new python version
+ self.assertTrue(len(p.details) > 1)
+
+ def test_detail_shouldFindMultipleStations(self):
+ # TODO Replace with assertGreater in new python version
+ self.assertTrue(len(p.details[0]) > 1)
+
+ def test_parser_overviewAndDetailsShouldHaveSameLength(self):
+ self.assertEqual(len(p.details), len(p.overview))
+
+ def test_parser_shouldFindMoreThanOneChange(self):
+ self.assertTrue(p.overview[0]['change'] > 0)
+
+ def test_parser_shouldFindPriceGreaterZero(self):
+ self.assertTrue(p.overview[0]['price'] > 0.0)
+
+ def test_parser_shouldFindDate(self):
+ self.assertTrue(p.overview[0]['date'] == dtime.date())
+
+
+if __name__ == '__main__':
+ unittest.main()
--- /dev/null
+
+import unittest
+
+# XXX: This is not really nice - we should use some kind of discovery
+
+from gotovienna.tests.realtime import *
+from gotovienna.tests.routing import *
+
+if __name__ == '__main__':
+ unittest.main()
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="69.099609"
+ height="34.263847"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.0 r9654"
+ sodipodi:docname="logo.svg"
+ inkscape:export-filename="logo.png"
+ inkscape:export-xdpi="100"
+ inkscape:export-ydpi="100">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.8"
+ inkscape:cx="162.5537"
+ inkscape:cy="87.339922"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1920"
+ inkscape:window-height="1170"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-55.714287,-69.844879)">
+ <text
+ xml:space="preserve"
+ style="font-size:24px;font-style:normal;font-weight:normal;line-height:69.99999881%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
+ x="55.714287"
+ y="89.505035"
+ id="text2985"
+ sodipodi:linespacing="69.999999%"><tspan
+ sodipodi:role="line"
+ id="tspan2987"
+ x="55.714287"
+ y="89.505035"
+ dy="0 -5.48"
+ dx="0 0"><tspan
+ style="font-size:40px;line-height:69.99999880999997970%;fill:#e30014;fill-opacity:0.94117647"
+ id="tspan2989"
+ dy="5.48"
+ dx="0"
+ rotate="0 0">g</tspan><tspan
+ style="font-size:28px"
+ id="tspan3267">oto</tspan></tspan><tspan
+ sodipodi:role="line"
+ x="55.714287"
+ y="104.10873"
+ dy="0 0 0 0 0 -0.02"
+ dx="0 0 0 0 0 0"
+ id="tspan3005"
+ style="font-size:16px;line-height:69.99999881%"> </tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:24px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
+ x="78.951591"
+ y="103.91048"
+ id="text3263"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan3265"
+ x="78.951591"
+ y="103.91048"
+ style="font-size:14px">vienna</tspan></text>
+ <text
+ xml:space="preserve"
+ style="font-size:24px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
+ x="41.289986"
+ y="81.858124"
+ id="text3269"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ id="tspan3271"
+ x="41.289986"
+ y="81.858124" /></text>
+ </g>
+</svg>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="69.099609"
- height="34.263847"
- id="svg2"
- version="1.1"
- inkscape:version="0.48.0 r9654"
- sodipodi:docname="logo.svg"
- inkscape:export-filename="logo.png"
- inkscape:export-xdpi="100"
- inkscape:export-ydpi="100">
- <defs
- id="defs4" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="2.8"
- inkscape:cx="162.5537"
- inkscape:cy="87.339922"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- inkscape:window-width="1920"
- inkscape:window-height="1170"
- inkscape:window-x="0"
- inkscape:window-y="0"
- inkscape:window-maximized="1"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0" />
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(-55.714287,-69.844879)">
- <text
- xml:space="preserve"
- style="font-size:24px;font-style:normal;font-weight:normal;line-height:69.99999881%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
- x="55.714287"
- y="89.505035"
- id="text2985"
- sodipodi:linespacing="69.999999%"><tspan
- sodipodi:role="line"
- id="tspan2987"
- x="55.714287"
- y="89.505035"
- dy="0 -5.48"
- dx="0 0"><tspan
- style="font-size:40px;line-height:69.99999880999997970%;fill:#e30014;fill-opacity:0.94117647"
- id="tspan2989"
- dy="5.48"
- dx="0"
- rotate="0 0">g</tspan><tspan
- style="font-size:28px"
- id="tspan3267">oto</tspan></tspan><tspan
- sodipodi:role="line"
- x="55.714287"
- y="104.10873"
- dy="0 0 0 0 0 -0.02"
- dx="0 0 0 0 0 0"
- id="tspan3005"
- style="font-size:16px;line-height:69.99999881%"> </tspan></text>
- <text
- xml:space="preserve"
- style="font-size:24px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
- x="78.951591"
- y="103.91048"
- id="text3263"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3265"
- x="78.951591"
- y="103.91048"
- style="font-size:14px">vienna</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:24px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
- x="41.289986"
- y="81.858124"
- id="text3269"
- sodipodi:linespacing="125%"><tspan
- sodipodi:role="line"
- id="tspan3271"
- x="41.289986"
- y="81.858124" /></text>
- </g>
-</svg>
+++ /dev/null
-import unittest
-import sys
-import os
-sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
-from iTip import iParser
-
-parser = iParser()
-
-class ParseTest(unittest.TestCase):
-
- def test_lines(self):
- lines = parser.lines
- self.assertTrue(type(lines) == dict)
- self.assertTrue(lines)
-
- def test_stations(self):
- lines = parser.lines
-
- s = []
- for line in lines:
- s.append(parser.get_stations(line[0]))
- self.assertTrue(s)
-
-if __name__ == '__main__':
- unittest.main()
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: UTF-8 -*-
-import unittest
-from scotty import search, ParserError, sParser, rParser, PageType
-from datetime import datetime
-from BeautifulSoup import BeautifulSoup
-
-dtime = datetime.now()
-dtime = dtime.replace(hour=15, minute=0)
-
-origin = u'Börse'.encode('UTF-8')
-destination = 'Handelskai'
-s = search((origin, 'stop'), (destination, 'stop'), dtime).read()
-parser = sParser(s)
-p = rParser(s)
-
-
-originc = 'Simmeri'
-destinationc = 'Karlspla'
-sc = search((originc, 'stop'), (destinationc, 'stop'), dtime).read()
-parserc = sParser(sc)
-
-
-origina = 'Zwicklgasse 1'
-destinationa = 'Himmelstrasse 1'
-ot = dt = 'address'
-
-
-originac = 'Foobar Strasse 123'
-destinationac = 'Bazgasse 321'
-
-
-class SearchTest(unittest.TestCase):
-
- def test_state(self):
- state = parser.check_page()
- statec = parserc.check_page()
-
- self.assertEqual(PageType.RESULT, state)
- self.assertEqual(PageType.CORRECTION, statec)
-
- def test_correction(self):
- cor = parserc.get_correction()
- s = search((cor[0][0], 'stop'), (cor[1][0], 'stop'), dtime).read()
- parser = sParser(s)
- self.assertEqual(PageType.RESULT, parser.check_page())
-
- def test_overview_shouldFindMultipleItems(self):
- # TODO Replace with assertGreater in new python version
- self.assertTrue(len(p.overview) > 1)
-
- def test_detail_shouldFindMultipleItems(self):
- # TODO Replace with assertGreater in new python version
- self.assertTrue(len(p.details) > 1)
-
- def test_detail_shouldFindMultipleStations(self):
- # TODO Replace with assertGreater in new python version
- self.assertTrue(len(p.details[0]) > 1)
-
- def test_parser_overviewAndDetailsShouldHaveSameLength(self):
- self.assertEqual(len(p.details), len(p.overview))
-
- def test_parser_shouldFindMoreThanOneChange(self):
- self.assertTrue(p.overview[0]['change'] > 0)
-
- def test_parser_shouldFindPriceGreaterZero(self):
- self.assertTrue(p.overview[0]['price'] > 0.0)
-
- def test_parser_shouldFindDate(self):
- self.assertTrue(p.overview[0]['date'] == dtime.date())
-
-
-if __name__ == '__main__':
- unittest.main()