コード例 #1
0
    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))
コード例 #2
0
    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")