Beispiel #1
0
class CdsBusStopIndexTestCase(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        logging.basicConfig(format='%(asctime)s - %(levelname)s [%(filename)s:%(lineno)s %(funcName)20s] %(message)s',
                            level=logging.INFO,
                            handlers=[logging.StreamHandler()])

        logger = logging.getLogger("vrnbus")
        self.mock_provider = CdsTestDataProvider(logger)
        self.cds = CdsRequest(logger, self.mock_provider)

    def test_get_index_by_name(self):
        result = self.cds.get_bus_stop_id("ул. Кирова (в центр)")
        self.assertIsInstance(result, int)

    def test_get_index_for_wrong_name(self):
        result = self.cds.get_bus_stop_id("NOT A STATION")
        self.assertIsInstance(result, int)
        self.assertEqual(result, -1)

    def test_get_bus_stop_for_index(self):
        result = self.cds.get_bus_stop_from_id(42)
        self.assertIsInstance(result, BusStop)

    def test_get_busstop_for_outrange_indexes(self):
        self.assertIsNone(self.cds.get_bus_stop_from_id(-1))
        self.assertIsNone(self.cds.get_bus_stop_from_id(100500))

    def test_routes_on_near_stations(self):
        # TODO: Find the test case for 49A
        routes_1 = self.cds.get_routes_on_bus_stop("Политехнический институт (из центра)")
        routes_2 = self.cds.get_routes_on_bus_stop("Рабочий проспект (из центра)")
        self.assertListEqual(routes_1, routes_2)
Beispiel #2
0
class CdsBusStopIndexTestCase(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        logging.basicConfig(
            format=
            '%(asctime)s - %(levelname)s [%(filename)s:%(lineno)s %(funcName)20s] %(message)s',
            level=logging.INFO,
            handlers=[logging.StreamHandler()])

        logger = logging.getLogger("vrnbus")
        self.mock_provider = CdsTestDataProvider(logger)
        self.cds = CdsRequest(logger, self.mock_provider)

    def test_get_index_by_name(self):
        result = self.cds.get_bus_stop_id("ул. Кирова (в центр)")
        self.assertIsInstance(result, int)

    def test_get_index_for_wrong_name(self):
        result = self.cds.get_bus_stop_id("NOT A STATION")
        self.assertIsInstance(result, int)
        self.assertEqual(result, -1)

    def test_get_index_by_name(self):
        result = self.cds.get_bus_stop_id("ул. Кирова (в центр)")
        self.assertIsInstance(result, int)

    def test_get_bus_stop_for_index(self):
        result = self.cds.get_bus_stop_from_id(42)
        self.assertIsInstance(result, BusStop)

    def test_get_busstop_for_outrange_indexes(self):
        self.assertIsNone(self.cds.get_bus_stop_from_id(-1))
        self.assertIsNone(self.cds.get_bus_stop_from_id(100500))