def testXml(self):
        xml_data = open("testdata/flightStatuses.xml").read()
        
        statuses = FlightStatusParser.parse_statuses(xml_data)
        self.assertEqual(5, len(statuses))
        
        expected = [ ("N", "New info"),
                     ("E", "New time"),
                     ("D", "Departed"),
                     ("A", "Arrived"),
                     ("C", "Cancelled"), ] 

        for e, s in zip(expected, statuses):
            self.assertEqual(e[0], s.code)
            self.assertEqual(e[1], s.text)
Exemplo n.º 2
0
def generate_status_factory():
    status_xml = download_status_xml()
    statuses = FlightStatusParser.parse_statuses(status_xml)
    status_factory = FlightStatusFactory(statuses)
    return status_factory
Exemplo n.º 3
0

(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)


print "Flight information for %s (%s)" % (airport.name, airport.code)

if not options.arrivals_only:
    print "\nDepartures:"
    for f in filter(is_departure, flights):
        print f