def testGetClosestNorwegianAirport(self): trd = AirPort("TRD", "Trondheim") trd.position = Position(63.45943, 10.92621) eve = AirPort("EVE", "Harstad") eve.position = Position(68.49111, 16.68057) in_airports = [ trd, eve ] factory = AirPortFactory(in_airports) a = factory.get_closest_norwegian_airport(Position(63.41330, 10.35962)) self.assertTrue("TRD", a.code)
def testGetNorwegianAirports(self): in_airports = [ AirPort("AES", "Ålesund"), AirPort("TRD", "Trondheim"), AirPort("CPH", "Copenhagen") ] factory = AirPortFactory(in_airports) airports = factory.get_norwegian_airports() self.assertEqual(2, len(airports)) self.assertTrue(find(lambda a: a.code == 'TRD', airports)) self.assertTrue(find(lambda a: a.code == 'AES', airports)) self.assertFalse(find(lambda a: a.code == 'CPH', airports))
def testGetNorwegianAirportsSorted(self): in_airports = [ AirPort("TRD", "Trondheim"), AirPort("OSL", "Oslo"), AirPort("OSY", "Namsos"), AirPort("VDB", "Fagernes"), AirPort("TRF", "Sandefjord") ] factory = AirPortFactory(in_airports) airports = factory.get_norwegian_airports() self.assertEqual(5, len(airports)) # Should be sorted by the name (not the code) self.assertEqual(airports[0].code, "VDB") self.assertEqual(airports[1].code, "OSY") self.assertEqual(airports[2].code, "OSL") self.assertEqual(airports[3].code, "TRF") self.assertEqual(airports[4].code, "TRD")
parser.add_option( "--arrivals", action="store_true", dest="arrivals_only", help="Print information about only arrivals.", default=False, ) (options, args) = parser.parse_args() airportname = args[0] airports_xml = FlightInformationService.download_airport_xml() airports = AirPortParser.parse_airports(airports_xml) airport_factory = AirPortFactory(airports) airlines_xml = FlightInformationService.download_airline_xml() airlines = AirlineParser.parse_airlines(airlines_xml) airline_factory = AirlineFactory(airlines) status_xml = FlightInformationService.download_flight_status_xml() statuses = FlightStatusParser.parse_statuses(status_xml) status_factory = FlightStatusFactory(statuses) airport = airport_factory.get_airport_by_code(airportname) query = Query(airport) xml = FlightInformationService.download_flight_xml(query) flights = FlightParser.parse_flights(xml, airline_factory, airport_factory, status_factory)
def testGetClosestNorwegianAirportEmptyList(self): in_airports = [] factory = AirPortFactory(in_airports) a = factory.get_closest_norwegian_airport(Position(0.0, 1.0)) self.assertTrue(a is None)