class TestFlight(unittest.TestCase): def setUp(self): self.flight = None self.airport = Airport() def test_flight_constructor(self): self.flight = Flight(start_time=Date(29, 11, 2016, hour='12:20'), end_time=Date(29, 11, 2016, hour='15:30'), passengers=100, max_passengers=120, from_dest="Sofia", to_dest="London", terminal=Terminal(2, 30), declined=False) def test_terminal_constructor(self): self.terminal = Terminal(number=1, max_flights=20) def test_passenger_constructor(self): self.passenger = Passenger(first_name="Rositsa", last_name="Zlateva", flight=Flight(), age=22) def test_reservation_constructor(self): self.reservation = Reservation(flight=Flight(), passenger=Passenger(), accepted=True) def test_get_flights_for(self): self.flight = constants.flights[2] self.assertEqual( self.airport.get_flights_for(Date(29, 11, 2016, hour='12:20'))[0], self.flight) def test_get_flight_before(self): self.assertEqual( self.airport.get_flights_before(Date(29, 11, 2016, hour='15:29')), [constants.flights[2]]) def test_get_flight_from(self): self.assertEqual(constants.flights[0], self.airport.get_flight_from('Sofia')[0]) def test_get_flight_to(self): self.assertEqual(constants.flights[0], self.airport.get_flight_to('Sofia')[0])
class TestAirport(unittest.TestCase): def setUp(self): self.airport = Airport(flights, passengers, reservations) def test_get_flights_for_date(self): date = Date(18, 11, 2016) flights = [flight_1, flight_3] self.assertEqual(self.airport.get_flights_for_date(date), flights) def test_get_flights_before(self): date = Date(19, 11, 2016) flights = [flight_1, flight_2, flight_3, flight_4] self.assertEqual(self.airport.get_flights_before(date, "23:59"), flights) def test_get_flights_from(self): flights = [flight_1, flight_2, flight_3, flight_4, flight_5] self.assertEqual(self.airport.get_flights_from("Sofia"), flights) def test_get_flights_to(self): flights = [flight_2] self.assertEqual(self.airport.get_flights_to("London"), flights) def test_flight_from(self): date = Date(18, 11, 2016) flights = [flight_1, flight_3] self.assertEqual(self.airport.get_flight_from("Sofia", date), flights) def test_flight_to(self): date = Date(18, 11, 2016) flights = [flight_1] self.assertEqual(self.airport.get_flight_to("Madrid", date), flights) def test_flights_on_date_lt_hours(self): date = Date(18, 11, 2016) flights = [flight_1] self.assertEqual(self.airport.flights_on_date_lt_hours(date, "04:25"), flights) def test_flights_within_duration(self): date = Date(18, 11, 2016) flights = [flight_1] self.assertEqual(self.airport.flights_on_date_lt_hours(date, "04:25"), flights) def test_passengers_under_18(self): self.assertEqual(self.airport.passengers_under_18(flight_3), [psng_3]) def test_passengers_to_dest(self): passengers = [psng_2, psng_7] self.assertEqual(self.airport.passengers_to_dest("London"), passengers) def test_passengers_from_terminal(self): passengers = [psng_1, psng_2, psng_6, psng_7] self.assertEqual(self.airport.passengers_from_terminal(terminal_1), passengers) def test_flights_with_passengers(self): flights = [flight_1, flight_4, flight_5] self.assertEqual(self.airport.flights_with_passengers(90), flights) def test_passengers_reservations(self): reservations = [res_1, res_6] self.assertEqual(self.airport.passengers_reservations(flight_1), reservations) def test_reservations_to_destionation(self): reservations = [res_2, res_7] self.assertEqual(self.airport.reservations_to_destination("London"), reservations)