class TestRESTHandler(unittest.TestCase):
    def setUp(self):
        self.query_strategy = StubQueryStrategy()
        self.lib = StationLibrary(self.query_strategy)
        self.station = self.lib.find_nearby(Position(0, 0))[0]
        self.handler = RESTHandler(self.query_strategy)

    def test_station_library_find_nearby(self):
        self.assertEqual(self.lib.find_nearby(Position(0, 0), 1000),
                         self.handler.handle(['1.0', 'Stations', 'findNearby'],
                                             {'long': '0', 'lat': 0, 'radius': 1000}))

    def test_get_station_from_name(self):
        s1 = self.lib.station_from_id(603330500).departures()
        s2 = self.handler.handle(['1.0', 'Stations', 'departures', '603330500'])
        self.assertEqual(s1, s2)
Example #2
0
class TestRESTHandler(unittest.TestCase):
    def setUp(self):
        self.query_strategy = StubQueryStrategy()
        self.lib = StationLibrary(self.query_strategy)
        self.station = self.lib.find_nearby(Position(0, 0))[0]
        self.handler = RESTHandler(self.query_strategy)

    def test_station_library_find_nearby(self):
        self.assertEqual(
            self.lib.find_nearby(Position(0, 0), 1000),
            self.handler.handle(['1.0', 'Stations', 'findNearby'], {
                'long': '0',
                'lat': 0,
                'radius': 1000
            }))

    def test_get_station_from_name(self):
        s1 = self.lib.station_from_id(603330500).departures()
        s2 = self.handler.handle(
            ['1.0', 'Stations', 'departures', '603330500'])
        self.assertEqual(s1, s2)
def setup_handler(strategy: QueryStrategy):
    handler = CustomRequestHandler
    handler.__REST_HANDLER__ = RESTHandler(strategy)
    return handler
Example #4
0
 def setUp(self):
     self.query_strategy = StubQueryStrategy()
     self.lib = StationLibrary(self.query_strategy)
     self.station = self.lib.find_nearby(Position(0, 0))[0]
     self.handler = RESTHandler(self.query_strategy)
 def setUp(self):
     self.query_strategy = StubQueryStrategy()
     self.lib = StationLibrary(self.query_strategy)
     self.station = self.lib.find_nearby(Position(0, 0))[0]
     self.handler = RESTHandler(self.query_strategy)