def addRoute(self, airport1, airport2, distance): newFlight = Flight.flight(airport1, airport2, distance) newReturnFlight = Flight.flight(airport2, airport1, distance) routeCode = newFlight.getRouteCode() returnRouteCode = newReturnFlight.getRouteCode() self.flightDictionary[routeCode] = newFlight self.flightDictionary[returnRouteCode] = newReturnFlight
def test_eq(self): self.assertTrue(self.fl1 == 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)) self.assertFalse(self.fl1 == Flight(start_time=Date(29, 11, 2016, hour='12:20'), end_time=Date(29, 11, 2016, hour='15:30'), passengers=100, max_passengers=1000, from_dest="Sofia", to_dest="London", terminal=Terminal(2, 30), declined=False))
def add_flight_suite(self, suite): for x in suite: src = self.airport_manager.get(x[0]) dst = self.airport_manager.get(x[1]) departure_time = x[2] cost = x[3] self.flight_manager.add(Flight(src, dst, departure_time, cost))
def cloneFlightPlan(self): # public FlightPlan cloneFlightPlan( ){ cloneList = list( ) # List<Flight> cloneList = Collections.synchronizedList(new ArrayList<Flight>()); for f in self.plan: # for (Flight f : this.plan){ cloneList.append( Flight.Flight(f)) ## cloneList.add( new Flight(f) ); return FlightPlan(cloneList) # return new FlightPlan(cloneList);
def test_allflights_constructor(self): self.assertEqual(self.all_fl.flights[0], 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 setUp(self): self.pssngr = Passenger(first_name="Rositsa", last_name="Zlateva", 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), age=22)
def test_get_flights_from_xml_correct_data(self): # Test LIST of FLIGHTS from XML file and CREATED with constructor are EQUAL flights_list_to_compare = [ Flight.Flight( 'AD832', 'Virgin America', Airport.Airport('John F. Kennedy International Airport', iata='JFK', icao='KJFK'), Airport.Airport('Los Angeles International Airport', iata='LAX', icao='KLAX')), Flight.Flight( 'AM13', 'S7', Airport.Airport('Pulkovo', iata='LED', icao='ULLI'), Airport.Airport('Domodedovo', iata='DME', icao='UUDD')) ] self.assertEqual(flights_list_to_compare, self.xml_flights_list)
class TestFlight(unittest.TestCase): def setUp(self): self.fl1 = 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) self.fl2 = Flight(start_time=Date(29, 11, 2016, hour='12:20'), end_time=Date(29, 11, 2016, hour='15:30'), passengers=120, max_passengers=120, from_dest="Sofia", to_dest="London", terminal=Terminal(2, 30), declined=False) def test_flight_empty_seats(self): self.assertTrue(self.fl1.flight_empty_seats()) self.assertFalse(self.fl2.flight_empty_seats()) def test_eq(self): self.assertTrue(self.fl1 == 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)) self.assertFalse(self.fl1 == Flight(start_time=Date(29, 11, 2016, hour='12:20'), end_time=Date(29, 11, 2016, hour='15:30'), passengers=100, max_passengers=1000, from_dest="Sofia", to_dest="London", terminal=Terminal(2, 30), declined=False)) def test_flight_constructor(self): self.assertEqual(self.fl1.start_time, Date(29, 11, 2016, hour='12:20')) self.assertEqual(self.fl1.end_time, Date(29, 11, 2016, hour='15:30')) self.assertEqual(self.fl1.passengers, 100) self.assertEqual(self.fl1.max_passengers, 120) self.assertEqual(self.fl1.from_dest, "Sofia") self.assertEqual(self.fl1.to_dest, "London") self.assertEqual(self.fl1.terminal, Terminal(2, 30)) self.assertFalse(self.fl1.declined) def test_flight_duration(self): self.assertEqual(self.fl1.flight_duration(), "03:10")
def main(): passenger1 = Passengers('1', 'David', 'BG2365215', '215487') passenger2 = Passengers('2', 'Dave', 'BG256398', '215487') passenger3 = Passengers('3', 'John', 'BG236589', '256369') passenger4 = Passengers('4', 'Susan', 'HG5236598', '256369') passenger5 = Passengers('5', 'Carol', 'BG2541896', '215487') passenger6 = Passengers('6', 'Karen', 'BG2563985', '215487') plane1 = Plane('300', '3265841', 'EasyJet') plane2 = Plane('600', '3265895', 'Alitalia') plane3 = Plane('700', '124578', 'Hamza') flight1 = Flight('215487', 'UK', 'Italy', '12.00') flight2 = Flight('256369', 'IT', 'UK', '12.00') flight3 = Flight('215487', 'SPAIN', 'MOROCCO', '12.00') done = False while done == False: print("""======AIRPORT MANAGEMENT====== 1. Display all the passengers 2. Display Aircrafts 3. Display Flight List 4. Add Passengers to flight """) choice = int(input("Enter Choice: ")) if choice == 1: for passenger in Passengers.get_list_object_passenger(): print(passenger.id + ' ' + passenger.name + ' ' + passenger._Passengers__passport + ' ' + passenger.passenger_flight_number) if choice == 2: for planes in Plane.get_list_plane_objects(): print(planes.capacity + ' ' + planes.plane_serial + ' ' + planes.airline) if choice == 3: #print(Flight.get_list_objsct()) for flights in Flight.get_list_objsct(): print(flights.flight_number + ' ' + flights.origin + ' ' + flights.destination + ' ' + flights.datetime) if choice == 4: new_list = [] for passenger in Passengers.get_list_object_passenger(): for planes in Flight.get_list_objsct(): if passenger.passenger_flight_number == planes.flight_number: new_list.append(passenger) new_list.append(planes) for item in new_list: print(item)
def add_flight_suite_for_airport(self, airport_index, suite): for x in suite: src = self.airport_manager.get(airport_index) dst = self.airport_manager.get(x[0]) departure_time = x[1] cost = x[2] index = self.flight_manager.add( Flight(src, dst, departure_time, cost)) x.insert(0, index)
def setUp(self): self.f1 = 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) self.all_fl = AllFlight(flight=self.f1) self.p1 = Passenger("Z", "A", self.f1 ,18)
def test_get_terminal_flights(self): self.f1 = 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) self.assertEqual(self.all_fl.get_terminal_flights(Terminal(1, 20)), []) self.assertEqual(self.all_fl.get_terminal_flights(Terminal(2, 20)), [self.f1])
def test_passenger_constructor(self): self.assertEqual(self.pssngr.first_name, "Rositsa") self.assertEqual(self.pssngr.last_name, "Zlateva") self.assertEqual(self.pssngr.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)) self.assertEqual(self.pssngr.age, 22)
def setUp(self): self.f1 = 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) self.res1 = Reservation(flight=self.f1, passenger=Passenger("Rositsa", "Zlateva", self.f1, 22), accepted=True)
def test_get_flights_from_xml_extra_data(self): # Test CORRECT LIST of flights is created if flights in xml have EXTRA ELEMENTS flights_list_to_compare = [ Flight.Flight( 'AD832', 'Virgin America', Airport.Airport('John F. Kennedy International Airport', iata='JFK', icao='KJFK'), Airport.Airport('Los Angeles International Airport', iata='LAX', icao='KLAX')), Flight.Flight( 'AM13', 'S7', Airport.Airport('Pulkovo', iata='LED', icao='ULLI'), Airport.Airport('Domodedovo', iata='DME', icao='UUDD')) ] self.assertEqual( flights_list_to_compare, Flight.Flight.get_flights_from_xml( '.\\test_data\\flights_extra_data.xml', self.airports_list))
def test_get_flights_from_xml_empty_flight_number(self): # Test CORRECT LIST of flights with EMPTY FLIGHT_NUMBER is created if FLIGHT_NUMBER attribute in xml is EMPTY flights_list_to_compare = [ Flight.Flight( '', 'Virgin America', Airport.Airport('John F. Kennedy International Airport', iata='JFK', icao='KJFK'), Airport.Airport('Los Angeles International Airport', iata='LAX', icao='KLAX')), Flight.Flight( '', 'S7', Airport.Airport('Pulkovo', iata='LED', icao='ULLI'), Airport.Airport('Domodedovo', iata='DME', icao='UUDD')) ] self.assertEqual( flights_list_to_compare, Flight.Flight.get_flights_from_xml( '.\\test_data\\flights_empty_flight_number.xml', self.airports_list))
def test_get_flights_from_csv_empty_flight_number_and_airline(self): # Test LIST with EMPTY AIRLINE AND FLIGHT_NUMBER is returned if FILE has EMPTY AIRLINE AND FLIGHT_NUMBER fields flights_list_to_compare = [ Flight.Flight( '', '', Airport.Airport('John F. Kennedy International Airport', iata='JFK', icao='KJFK'), Airport.Airport('Los Angeles International Airport', iata='LAX', icao='KLAX')), Flight.Flight( '', '', Airport.Airport('Pulkovo', iata='LED', icao='ULLI'), Airport.Airport('Domodedovo', iata='DME', icao='UUDD')) ] self.assertEqual( flights_list_to_compare, Flight.Flight.get_flights_from_csv( '.\\test_data\\flights_empty_flight_number_and_airline.csv', self.airports_list, csv_header=True))
def test_eq_diff(self): # Make sure __eq__ method states 2 DIFF flights are NOT equal self.assertNotEqual( self.flight_ex, Flight.Flight('AM13', 'S7', airport_from=Airport.Airport('Pulkovo', iata='LED', icao='ULLI'), airport_to=Airport.Airport('Domodedovo', iata='DME', icao='UUDD')))
def simulateFlight(coreFunctions, simParams, airportEnvironment, airspace, costParameters, weather, state, flightParams, instructions): # (coreFunctions:SimulationCoreFunctions) (simParams:SimulationParameters) airportEnvironment airspace # costParameters (weather:WeatherState) (state:FlightState) (flightParams:FlightParameters) (instructions:Route) = instructionStatus, remainingSteps, log, endState = Flight.runInstructions( coreFunctions, simParams, flightParams, weather, airspace, state, instructions) reachedArrivalPoint = (instructionStatus != 'Failed' and simParams['LandingMode'] != SimulationParameters.LandingMode.NoLanding \ and Arrival.withinArrivalZone(flightParams, endState)) landed = False if reachedArrivalPoint: weight = coreFunctions.WeightModel(flightParams, endState) time = Units.timeIncrement(flightParams.ActualGateDepartureTime, endState.TimeElapsed) landingState = coreFunctions.ArrivalModel(flightParams) #airportEnvironment, FuelModel.flightFunctions, # flightParams, endState.AircraftPosition, weight, # time) updatedState = Flight.updateSimulationState(endState, landingState) # // Check that fuel tank was not exhausted during arrival if updatedState.FuelConsumed > flightParams.InitialFuel: airport = flightParams.DestinationAirport message = Messages.FuelExhausted(flightParams.FlightId, endState.AircraftPosition) Flight.addMessageToState(updatedState, message) else: landed = True results = updatedState else: airport = flightParams.DestinationAirport # print airport message = Messages.CannotLand( flightParams.FlightId, endState.AircraftPosition, airport.Code) Flight.addMessageToState(endState, message) results = endState fuelConsumed = Units.fuelPoundsToFuelGallons(results.FuelConsumed) delay = None if landed: arrivalTime = Units.timeIncrement(flightParams.ActualGateDepartureTime, results.TimeElapsed) delay = Units.timeDifference(arrivalTime, flightParams.ScheduledGateArrivalTime) costs = CostModel.flightCost(costParameters, instructions, flightParams.Payload, fuelConsumed, delay, results.TimeElapsedInTurbulence) # // Add final record to flight log (east,north,altitude) = results.AircraftPosition finalLogEntry = FlightTypes.FlightLogEntry( FlightId = flightParams.FlightId, Latitude = 0.0, # <Latitude> Longitude = 0.0, # <Longitude> Easting = east, Northing = north, ElapsedTime = results.TimeElapsed, AirSpeed = 0.0, # <Knots> GroundSpeed = 0.0, #<Knots> Altitude = altitude, FuelConsumed = results.FuelConsumed, Weight = coreFunctions.WeightModel(flightParams, results), InRestrictedZones = False, InTurbulentZones = False, Status = 'Landed' if landed else 'Crashed' ) updatedLog = log.append(finalLogEntry) return { 'FlightId' : flightParams.FlightId, 'Duration' : results.TimeElapsed, 'FuelBurned' : results.FuelConsumed, 'Messages' : results.Messages, 'Log' : updatedLog, 'ReachedDestination' : landed, 'CostDetail' : costs, 'Cost' : CostModel.accumulateCosts(costs) }