def run_router_with_reconstruction_test(router_type, from_stop, to_stop, des_dep_time_hhmmss, exp_nb_legs, exp_nb_pt_legs, exp_first_stop, exp_last_stop, exp_dep_time_hhmmss, exp_arr_time_hhmmss, exp_pt_in_stops, exp_pt_out_stops): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) router = None if router_type == RouterWithReconstructionType.UNOPTIMIZED_EARLIEST_ARRIVAL_WITH_RECONSTRUCTION: router = cs_core.route_earliest_arrival_with_reconstruction elif router_type == RouterWithReconstructionType.OPTIMIZED_EARLIEST_ARRIVAL_WITH_RECONSTRUCTION: router = cs_core.route_optimized_earliest_arrival_with_reconstruction else: ValueError("router not known") journey = router(from_stop.id, to_stop.id, hhmmss_to_sec(des_dep_time_hhmmss)) assert exp_nb_legs == journey.get_nb_journey_legs() assert exp_nb_pt_legs == journey.get_nb_pt_journey_legs() assert (exp_first_stop.id if exp_first_stop is not None else None) == journey.get_first_stop_id() assert (exp_last_stop.id if exp_last_stop is not None else None) == journey.get_last_stop_id() assert (exp_dep_time_hhmmss if exp_dep_time_hhmmss else None) == seconds_to_hhmmss(journey.get_dep_time()) assert (exp_arr_time_hhmmss if exp_arr_time_hhmmss else None) == seconds_to_hhmmss(journey.get_arr_time()) assert [s.id for s in exp_pt_in_stops] == journey.get_pt_in_stop_ids() assert [s.id for s in exp_pt_out_stops] == journey.get_pt_out_stop_ids()
def test_unoptimized_earliest_arrival_bern_duebystrasse_ostermundigen_bahnhof( ): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) assert "12:34:00" == seconds_to_hhmmss( cs_core.route_earliest_arrival(bern_duebystrasse.id, ostermundigen_bahnhof.id, hhmmss_to_sec("12:09:46")))
def test_unoptimized_earliest_arrival_bern_samedan(): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) assert "12:45:00" == seconds_to_hhmmss( cs_core.route_earliest_arrival(bern.id, samedan.id, hhmmss_to_sec("08:30:00"))) assert cs_core.route_earliest_arrival(bern.id, samedan.id, hhmmss_to_sec("21:00:00")) is None
def test_unoptimized_earliest_arrival_bern_zuerich_hb(): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) assert "08:58:00" == seconds_to_hhmmss( cs_core.route_earliest_arrival(bern.id, zuerich_hb.id, hhmmss_to_sec("07:35:00"))) assert "08:58:00" == seconds_to_hhmmss( cs_core.route_earliest_arrival(bern.id, zuerich_hb.id, hhmmss_to_sec("08:02:00"))) assert cs_core.route_earliest_arrival(bern.id, zuerich_hb.id, hhmmss_to_sec("23:33:00")) is None
def test_unoptimized_earliest_arrival_with_reconstruction_by_name_bern_bahnhof_samedan_bahnhof( ): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) journey = cs_core.route_earliest_arrival_with_reconstruction_by_name( bern_bahnhof.name, samedan_bahnhof.name, "08:26:00") assert 4 == journey.get_nb_journey_legs() assert 3 == journey.get_nb_pt_journey_legs() assert bern_bahnhof.id == journey.get_first_stop_id() assert samedan_bahnhof.id == journey.get_last_stop_id() assert "08:27:00" == seconds_to_hhmmss(journey.get_dep_time()) assert "12:48:00" == seconds_to_hhmmss(journey.get_arr_time()) assert [bern.id, zuerich_hb.id, chur.id] == journey.get_pt_in_stop_ids() assert [zuerich_hb.id, chur.id, samedan.id] == journey.get_pt_out_stop_ids()
def test_unoptimized_earliest_arrival_by_name_bern_bern_bahnhof(): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) assert "12:14:46" == seconds_to_hhmmss( cs_core.route_earliest_arrival_by_name(bern.name, bern_bahnhof.name, "12:09:46"))
def test_unoptimized_earliest_arrival_bern_bern(): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) assert "12:09:46" == seconds_to_hhmmss( cs_core.route_earliest_arrival(bern.id, bern.id, hhmmss_to_sec("12:09:46")))
def test_unoptimized_earliest_arrival_basel_st_gallen(): cs_data = create_test_connectionscan_data() cs_core = ConnectionScanCore(cs_data) assert "09:41:00" == seconds_to_hhmmss( cs_core.route_earliest_arrival(basel_sbb.id, st_gallen.id, hhmmss_to_sec("07:30:00")))