Example #1
0
 def setUp(self):
     self.node_class = TakeoffDatetime
     self.takeoff_datetime = self.node_class()
     self.takeoff_datetime.set_flight_attr = Mock()
     self.start_dt = A('Start Datetime', value=datetime(1970, 1, 1))
     self.liftoff = KTI(name='Liftoff', frequency=2, items=[
         KeyTimeInstance(index=64),
     ])
     self.rto = buildsection('Rejected Takeoff', 15, 20)
     self.off_blocks = KTI(name='Off Blocks', frequency=0.25, items=[
         KeyTimeInstance(index=3),
     ])
Example #2
0
    def test_derive(self):
        '''
        Tests every flow, but does not test every conceivable set of arguments.
        '''
        type_node = FlightType()
        type_node.set_flight_attr = Mock()
        # Liftoff and Touchdown.
        fast = S('Fast', items=[slice(5,10)])
        liftoffs = KTI('Liftoff', items=[KeyTimeInstance(5, 'a')])
        touchdowns = KTI('Touchdown', items=[KeyTimeInstance(10, 'x')])
        type_node.derive(None, fast, None, liftoffs, touchdowns, None, None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.COMPLETE)
        # Would be 'COMPLETE', but 'AFR Type' overrides it.
        afr_type = A('AFR Type', value=FlightType.Type.FERRY)
        type_node.set_flight_attr = Mock()
        type_node.derive(afr_type, fast, None, liftoffs, touchdowns, None, None, None)
        type_node.set_flight_attr.assert_called_once_with(FlightType.Type.FERRY)
        # Liftoff missing.
        empty_liftoffs = KTI('Liftoff')
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(None, fast, None, empty_liftoffs, touchdowns, None, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'TOUCHDOWN_ONLY')
        # Touchdown missing.
        empty_touchdowns = KTI('Touchdown')
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(None, fast, None, liftoffs, empty_touchdowns, None, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'LIFTOFF_ONLY')

        # Liftoff and Touchdown missing, only Fast.
        type_node.set_flight_attr = Mock()
        type_node.derive(None, fast, None, empty_liftoffs, empty_touchdowns, None,
                         None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.INCOMPLETE)
        # Liftoff, Touchdown and Fast missing.
        empty_fast = fast = S('Fast')
        type_node.set_flight_attr = Mock()
        type_node.derive(None, empty_fast, None, empty_liftoffs, empty_touchdowns,
                         None, None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.INCOMPLETE)
        # Liftoff, Touchdown and Fast missing, RTO.
        rto = buildsection('Rejected Takeoff', 5, 10)
        type_node.set_flight_attr = Mock()
        type_node.derive(None, empty_fast, None, empty_liftoffs, empty_touchdowns,
                         None, rto, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.REJECTED_TAKEOFF)
        # Liftoff after Touchdown.
        late_liftoffs = KTI('Liftoff', items=[KeyTimeInstance(20, 'a')])
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(None, fast, None, late_liftoffs, touchdowns, None, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'TOUCHDOWN_BEFORE_LIFTOFF')
        # Touch and Go before Touchdown.
        afr_type = A('AFR Type', value=FlightType.Type.TRAINING)
        touch_and_gos = KTI('Touch And Go', items=[KeyTimeInstance(7, 'a')])
        type_node.set_flight_attr = Mock()
        type_node.derive(afr_type, fast, None, liftoffs, touchdowns, touch_and_gos,
                         None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.TRAINING)
        # Touch and Go after Touchdown.
        afr_type = A('AFR Type', value=FlightType.Type.TRAINING)
        touch_and_gos = KTI('Touch And Go', items=[KeyTimeInstance(15, 'a')])
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(afr_type, fast, None, liftoffs, touchdowns,
                             touch_and_gos, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'LIFTOFF_ONLY')