def test_known_routes_world(self): route = self.router.route(Destination(postcode='66400', country='FR')) self.assertDicEq( route.routingdata(), { 'd_depot': '0470', 'serviceinfo': '', 'country': 'FR', 'd_sort': 'U50', 'o_sort': '16', 'service_text': 'D' }) route = self.router.route(Destination('FR', '66400', 'Ceret')) self.assertDicEq( route.routingdata(), { 'd_depot': '0470', 'serviceinfo': '', 'country': 'FR', 'd_sort': 'U50', 'o_sort': '16', 'service_text': 'D' }) route = self.router.route(Destination('BE', '3960', 'Bree/Belgien')) self.assertDicEq( route.routingdata(), { 'd_depot': '0532', 'serviceinfo': '', 'country': 'BE', 'd_sort': 'A353', 'o_sort': '52', 'service_text': 'D' }) route = self.router.route(Destination('CH', '6005', 'Luzern')) self.assertDicEq( route.routingdata(), { 'd_depot': '0616', 'serviceinfo': '', 'country': 'CH', 'd_sort': '40', 'o_sort': '78', 'service_text': 'D' }) route = self.router.route(Destination('AT', '1210', 'Wien')) self.assertDicEq( route.routingdata(), { 'd_depot': '0622', 'serviceinfo': '', 'country': 'AT', 'd_sort': '10', 'o_sort': '62', 'service_text': 'D' }) route = self.router.route(Destination('AT', '4820', 'Bad Ischl')) self.assertDicEq( route.routingdata(), { 'd_depot': '0624', 'serviceinfo': '', 'country': 'AT', 'd_sort': '63', 'o_sort': '62', 'service_text': 'D' }) route = self.router.route(Destination('AT', '7400', 'Oberwart')) self.assertDicEq( route.routingdata(), { 'd_depot': '0628', 'serviceinfo': '', 'country': 'AT', 'd_sort': '3270', 'o_sort': '62', 'service_text': 'D' }) route = self.router.route(Destination('AT', '4400', 'Steyr')) self.assertDicEq( route.routingdata(), { 'd_depot': '0624', 'serviceinfo': '', 'country': 'AT', 'd_sort': '70', 'o_sort': '62', 'service_text': 'D' }) route = self.router.route(Destination('AT', '1220', 'Wien')) self.assertDicEq( route.routingdata(), { 'd_depot': '0622', 'serviceinfo': '', 'country': 'AT', 'd_sort': '30', 'o_sort': '62', 'service_text': 'D' }) route = self.router.route(Destination('AT', '6890', 'Lustenau')) self.assertDicEq( route.routingdata(), { 'd_depot': '0627', 'serviceinfo': '', 'country': 'AT', 'd_sort': '01', 'o_sort': '62', 'service_text': 'D' }) route = self.router.route(Destination('BE', '3520', 'ZONHOVEN')) self.assertDicEq( route.routingdata(), { 'd_depot': '0532', 'serviceinfo': '', 'country': 'BE', 'd_sort': 'A369', 'o_sort': '52', 'service_text': 'D' }) route = self.router.route(Destination('BE', '4890', 'Thimister')) self.assertDicEq( route.routingdata(), { 'd_depot': '0532', 'serviceinfo': '', 'country': 'BE', 'd_sort': 'B326', 'o_sort': '52', 'service_text': 'D' }) route = self.router.route(Destination('CH', '8305', 'Dietlikon')) self.assertDicEq( route.routingdata(), { 'd_depot': '0615', 'serviceinfo': '', 'country': 'CH', 'd_sort': '77', 'o_sort': '78', 'service_text': 'D' }) route = self.router.route(Destination('CH', '4051', 'Basel')) self.assertDicEq( route.routingdata(), { 'd_depot': '0610', 'serviceinfo': '', 'country': 'CH', 'd_sort': '16', 'o_sort': '78', 'service_text': 'D' }) route = self.router.route(Destination('CH', '8808', 'Pf<C3><A4>ffikon')) self.assertDicEq( route.routingdata(), { 'd_depot': '0615', 'serviceinfo': '', 'country': 'CH', 'd_sort': '71', 'o_sort': '78', 'service_text': 'D' }) route = self.router.route(Destination('DK', '9500', 'Hobro')) self.assertDicEq( route.routingdata(), { 'd_depot': '0504', 'serviceinfo': '', 'country': 'DK', 'd_sort': '405', 'o_sort': '20', 'service_text': 'D' }) # Lichtenstein is routed via CH route = self.router.route( Destination('LI', '8399', 'Windhof / Luxembourg')) self.assertDicEq( route.routingdata(), { 'd_depot': '0617', 'serviceinfo': '', 'country': 'CH', 'd_sort': '', 'o_sort': '78', 'service_text': 'D' }) route = self.router.route(Destination('LI', '9495', 'Triesen')) self.assertDicEq( route.routingdata(), { 'd_depot': '0617', 'serviceinfo': '', 'country': 'CH', 'd_sort': '', 'o_sort': '78', 'service_text': 'D' }) route = self.router.route(Destination('LI', '8440', 'Steinfort')) self.assertDicEq( route.routingdata(), { 'd_depot': '0617', 'serviceinfo': '', 'country': 'CH', 'd_sort': '', 'o_sort': '78', 'service_text': 'D' }) route = self.router.route(Destination('CZ', '41742', 'Krupka 1')) self.assertDicEq( route.routingdata(), { 'd_depot': '1380', 'serviceinfo': '', 'country': 'CZ', 'd_sort': '21', 'o_sort': '10', 'service_text': 'D' }) route = self.router.route( Destination('ES', '28802', 'Alcala de Henares (Madrid)')) self.assertDicEq( route.routingdata(), { 'd_depot': '0728', 'serviceinfo': '', 'country': 'ES', 'd_sort': '01', 'o_sort': '16', 'service_text': 'D' }) route = self.router.route(Destination('ES', '28010', 'Madrid')) self.assertDicEq( route.routingdata(), { 'd_depot': '0728', 'serviceinfo': '', 'country': 'ES', 'd_sort': '01', 'o_sort': '16', 'service_text': 'D' }) route = self.router.route(Destination('FR', '84170', 'MONTEUX')) self.assertDicEq( route.routingdata(), { 'd_depot': '0447', 'serviceinfo': '', 'country': 'FR', 'd_sort': 'S65', 'o_sort': '16', 'service_text': 'D' }) route = self.router.route(Destination('FR', '91044', 'Evry Cedex')) self.assertDicEq( route.routingdata(), { 'd_depot': '0408', 'serviceinfo': '', 'country': 'FR', 'd_sort': 'S61', 'o_sort': '50', 'service_text': 'D' })
'o_sort': '78', 'serviceinfo': '', 'barcode_id': '37', 'grouping_priority': '', 'country': 'CH', 'countrynum': '756', 'routingtable_version': '20110905', 'iata_code': '', 'd_sort': '', 'postcode': '8440', 'd_depot': '0617', 'service_text': 'D' }) def test_cache(self): self.assertEqual(vars(get_route('LI', '8440')), vars(get_route_without_cache('LI', '8440'))) if __name__ == '__main__': start = time.time() router = Router(RouteData()) stamp = time.time() router.route(Destination('AT', '4240', 'Freistadt Österreich')).routingdata() end = time.time() # print ("took %.3fs to find a single route (including %.3fs initialisation overhead)" # % (end-start, stamp-start)) unittest.main()