async def go(LOOP):
            APIClient = MockAPIClient()

            sf_reader = ShapefileService(APIClient)

            frinfo = await sf_reader.get_stop_infos("Scherdemael")
            print(frinfo)
            nlinfo = await sf_reader.get_stop_infos("Scherdemaal")

            self.assertEqual(
                frinfo.get_line_info(46).get_line_color(),
                nlinfo.get_line_info(46).get_line_color())
            self.assertEqual(
                frinfo.get_line_info(46).get_line_type(),
                nlinfo.get_line_info(46).get_line_type())
            self.assertEqual(
                frinfo.get_line_info(46).get_line_nr(),
                nlinfo.get_line_info(46).get_line_nr())

            l46 = await sf_reader.get_line_info(46)
            self.assertEqual(l46.get_line_color(), "#DE3B21")
            self.assertEqual(l46.get_line_text_color(), "#FFFFFF")
            self.assertEqual(l46.get_line_type(), "B")
            self.assertEqual(l46.get_line_nr(), 46)

            await check_color(sf_reader, 3, "#000000")
            await check_color(sf_reader, 5, "#FFFFFF")
            await check_color(sf_reader, 6, "#FFFFFF")
Esempio n. 2
0
        async def go(LOOP):
            stop_name = "De Brouckère"
            lines_filter = [(5, 1)]
            custom_session = aiohttp.ClientSession()

            APIClient = MockAPIClient()

            service = STIBService(APIClient)
            exception = "Unraised"
            try:
                passages = await service.get_passages(stop_name,
                                                      lines_filter,
                                                      now=datetime.datetime(
                                                          2020,
                                                          1,
                                                          28,
                                                          hour=23,
                                                          minute=59,
                                                          second=52))
            except NoScheduleFromAPIException as e:
                exception = "Raised"
                passages = e.get_next_passages()
            self.assertEqual(exception, "Raised")
            self.assertGreaterEqual(len(passages), 1)
            self.assertEqual(passages[0]['expected_arrival_time'],
                             '2020-01-29T00:06:31')
        async def go(LOOP):
            APIClient = MockAPIClient()

            sf_reader = ShapefileService(APIClient)

            info = await sf_reader.get_stop_infos("Scherdemael")

            self.assertAlmostEqual(info.get_location()["lat"],
                                   50.8311,
                                   delta=0.0001)
            self.assertAlmostEqual(info.get_location()["lon"],
                                   4.2896,
                                   delta=0.0001)
Esempio n. 4
0
        async def go(LOOP):
            stop_name = "foobar"

            APIClient = MockAPIClient()

            service = STIBService(APIClient)
            res = "No exception raised"
            try:
                passages = await service.get_passages(stop_name)
            except InvalidStopNameException as e:
                res = "InvalidStopNameException raised!"

            self.assertEqual(res, "InvalidStopNameException raised!")
Esempio n. 5
0
        async def go(LOOP):
            stop_name = "scherdemael"
            lines_filter = [(46, "Glibert")]
            custom_session = aiohttp.ClientSession()

            APIClient = MockAPIClient()

            service = STIBService(APIClient)
            passages = await service.get_passages(stop_name, lines_filter)

            print(json.dumps(passages))

            await custom_session.close()
Esempio n. 6
0
        async def go(LOOP):
            stop_name = "Scherdemael"
            lines_filter = [(104, 1)]
            custom_session = aiohttp.ClientSession()

            APIClient = MockAPIClient()

            service = STIBService(APIClient)

            hasRaised = False
            try:
                await service.get_passages(stop_name,
                                           lines_filter,
                                           lang_message='fr',
                                           lang_stop_name='fr')
            except InvalidLineFilterException:
                hasRaised = True

            self.assertTrue(hasRaised)
Esempio n. 7
0
        async def go(LOOP):
            stop_name = "Scherdemael"
            lines_filter = [(46, 1)]
            custom_session = aiohttp.ClientSession()

            APIClient = MockAPIClient()

            service = STIBService(APIClient)
            passages = await service.get_passages(stop_name,
                                                  lines_filter,
                                                  lang_message='fr',
                                                  lang_stop_name='fr')

            now = datetime.datetime.now()
            delta1 = datetime.timedelta(minutes=3, seconds=25)
            delta2 = datetime.timedelta(minutes=13, seconds=22)

            # Check message
            self.assertEqual(passages[0]["message"], "foofr")
            self.assertEqual(passages[1]["message"], "")
        async def go(LOOP):
            APIClient = MockAPIClient()

            sf_reader = ShapefileService(APIClient)

            info = await sf_reader.get_stop_infos("Scherdemael")

            print(info.get_locations())
            self.assertAlmostEqual(info.get_locations()['3755']["lat"],
                                   50.8312,
                                   delta=0.0001)
            self.assertAlmostEqual(info.get_locations()['3755']["lon"],
                                   4.2900,
                                   delta=0.0001)

            self.assertAlmostEqual(info.get_locations()['3713']["lat"],
                                   50.8309,
                                   delta=0.0001)
            self.assertAlmostEqual(info.get_locations()['3713']["lon"],
                                   4.2892,
                                   delta=0.0001)
        async def go(LOOP):
            APIClient = MockAPIClient()

            sf_reader = ShapefileService(APIClient)

            now = datetime.now()
            info = await sf_reader.get_next_stop_passage('3755', now)
            self.assertLess(now, info)
            info = await sf_reader.get_next_stop_passage(
                '3755', datetime(2020, 1, 28, hour=2, minute=32, second=2))
            self.assertEqual(
                info, datetime(2020, 1, 28, hour=5, minute=7, second=27))
            info = await sf_reader.get_next_stop_passage(
                '3755', datetime(2020, 1, 28, hour=5, minute=10, second=2))
            self.assertEqual(
                info, datetime(2020, 1, 28, hour=5, minute=18, second=27))
            info = await sf_reader.get_next_stop_passage(
                '3755', datetime(2020, 1, 28, hour=23, minute=58, second=2))
            self.assertEqual(
                info, datetime(2020, 1, 28, hour=23, minute=59, second=51))
            info = await sf_reader.get_next_stop_passage(
                '3755', datetime(2020, 1, 28, hour=23, minute=59, second=52))
            self.assertEqual(
                info, datetime(2020, 1, 29, hour=5, minute=7, second=27))