Beispiel #1
0
 def test_recommended_route_for_passenger(self, pass_id, expected):
     route = Route(TEST_DIR / "route.csv")
     passengers = read_passengers(TEST_DIR / "passenger.csv")
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     route_for_passenger = journey.recommended_route_for_passenger(pass_id)
     assert print(route_for_passenger) == print(expected)
Beispiel #2
0
 def test_travel_time(self, pass_id, expected):
     route = Route(TEST_DIR / "route.csv")
     passengers = read_passengers(TEST_DIR / "passenger.csv")
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     travel_time = journey.travel_time(pass_id)
     assert travel_time == expected
Beispiel #3
0
 def test_plot_bus_load(self, route, passengers, expected):
     route = Route(TEST_DIR / route)
     passengers = read_passengers(TEST_DIR / passengers)
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     bus_plot_load = journey.plot_bus_load(isTesting=1)
     assert bus_plot_load == expected
Beispiel #4
0
 def test_passenger_trip_time(self, passenger, expected):
     route = Route(TEST_DIR / "route.csv")
     passengers = read_passengers(TEST_DIR / "passenger.csv")
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     pass_trip_time = journey.passenger_trip_time(passenger, isTesting=1)
     assert pass_trip_time == expected
Beispiel #5
0
 def test_passenger_journey_allowed(self, passenger, expected):
     route = Route(TEST_DIR / "route.csv")
     passengers = read_passengers(TEST_DIR / "passenger.csv")
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     journey_allowed = journey.passenger_journey_allowed(passenger)
     assert journey_allowed == expected
Beispiel #6
0
 def test_passenger_trip(self, passenger):
     with pytest.raises(Exception):
         route = Route(TEST_DIR / "route.csv")
         passengers = read_passengers(TEST_DIR / "passenger.csv")
         passengers_ls = passengers_list(passengers)
         journey = Journey(route, passengers_ls)
         journey.passenger_trip(passenger)
Beispiel #7
0
def process():
    parser = ArgumentParser(description=("Finds the best route option for a"
                            "passenger."),
                            formatter_class=ArgumentDefaultsHelpFormatter)

    parser.add_argument('routefile',
                        help="Input CSV file with the route of the bus.")

    parser.add_argument('passfile',
                        help=("Input CSV file with the passengers journey"
                              "details."))

    parser.add_argument('--speed', '-s', type=int, default=10,
                        help="Speed of the bus.")

    parser.add_argument('--saveplots', '-sps', default=None,
                        action="store_true",
                        help="Saving the plots of bus load.")

    arguments = parser.parse_args()
    route_ins = Route(route=arguments.routefile, bus_speed=arguments.speed)
    passengers = read_passengers(arguments.passfile)
    timetable = route_ins.timetable()
    passengers_ls = passengers_list(passengers)
    journey = Journey(route_ins, passengers_ls)
    save_bus_map = route_ins.plot_map(save_plot=arguments.saveplots)
    save_bus_load = journey.plot_bus_load(save_plot=arguments.saveplots)
    print(timetable)
    for i in range(len(passengers_ls)):
        print(journey.recommended_route_for_passenger(i))

    return 0
Beispiel #8
0
 def test_passenger_get_on_off_bus_stop_name(self, passenger, expected):
     route = Route(TEST_DIR / "route.csv")
     passengers = read_passengers(TEST_DIR / "passenger.csv")
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     get_on_bus = journey.passenger_trip_time(passenger)[2]
     get_off_bus = journey.passenger_trip_time(passenger)[3]
     assert (get_on_bus, get_off_bus) == expected
Beispiel #9
0
 def test_print_time_stats(self, route, passengers, expected):
     route = Route(TEST_DIR / route)
     passengers = read_passengers(TEST_DIR / passengers)
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     assert journey.print_time_stats() == print(expected)
Beispiel #10
0
 def test_passenger_walk_bus_stop(self, passenger, expected):
     route = Route(TEST_DIR / "route.csv")
     passengers = read_passengers(TEST_DIR / "passenger.csv")
     passengers_ls = passengers_list(passengers)
     journey = Journey(route, passengers_ls)
     assert journey.passenger_walk_bus_stop(passenger) == expected