示例#1
0
    def test__controls_in_use(self):
        pitch_capt = Mock()
        pitch_fo = Mock()
        roll_capt = Mock()
        roll_fo = Mock()

        section = Section('Takeoff', slice(0, 3), 0, 3)

        # Note: We instantiate one of the subclasses of DeterminePilot as we
        #       use logging methods not defined in this abstract superclass.
        determine_pilot = LandingPilot()
        determine_pilot._controls_changed = Mock()

        # Neither pilot's controls changed:
        determine_pilot._controls_changed.reset_mock()
        determine_pilot._controls_changed.side_effect = [False, False]
        pilot = determine_pilot._controls_in_use(pitch_capt, pitch_fo, roll_capt, roll_fo, section)
        determine_pilot._controls_changed.assert_has_calls([
            call(section.slice, pitch_capt, roll_capt),
            call(section.slice, pitch_fo, roll_fo),
        ])
        self.assertEqual(pilot, None)
         # Only captain's controls changed:
        determine_pilot._controls_changed.reset_mock()
        determine_pilot._controls_changed.side_effect = [True, False]
        pilot = determine_pilot._controls_in_use(pitch_capt, pitch_fo, roll_capt, roll_fo, section)
        determine_pilot._controls_changed.assert_has_calls([
            call(section.slice, pitch_capt, roll_capt),
            call(section.slice, pitch_fo, roll_fo),
        ])
        self.assertEqual(pilot, 'Captain')
        # Only first Officer's controls changed:
        determine_pilot._controls_changed.reset_mock()
        determine_pilot._controls_changed.side_effect = [False, True]
        pilot = determine_pilot._controls_in_use(pitch_capt, pitch_fo, roll_capt, roll_fo, section)
        determine_pilot._controls_changed.assert_has_calls([
            call(section.slice, pitch_capt, roll_capt),
            call(section.slice, pitch_fo, roll_fo),
        ])
        self.assertEqual(pilot, 'First Officer')
        # Both pilot's controls changed:
        determine_pilot._controls_changed.reset_mock()
        determine_pilot._controls_changed.side_effect = [True, True]
        pilot = determine_pilot._controls_in_use(pitch_capt, pitch_fo, roll_capt, roll_fo, section)
        determine_pilot._controls_changed.assert_has_calls([
            call(section.slice, pitch_capt, roll_capt),
            call(section.slice, pitch_fo, roll_fo),
        ])
        self.assertEqual(pilot, None)
示例#2
0
 def test_can_operate(self):
     opts = LandingPilot.get_operational_combinations()
     combinations = [
         # Only Pilot Flying
         ('Pilot Flying', 'Landing'),
         # Only Controls:
         ('Pitch (Capt)', 'Pitch (FO)', 'Roll (Capt)', 'Roll (FO)', 'Landing'),
         # Only Control Column Forces:
         ('Control Column Force (Capt)', 'Control Column Force (FO)', 'Landing'),
         # Only Autopilot:
         ('AP (1) Engaged', 'AP (2) Engaged', 'Touchdown'),
         # Everything:
         ('Pilot Flying',
          'Pitch (Capt)', 'Pitch (FO)', 'Roll (Capt)', 'Roll (FO)',
          'Control Column Force (Capt)', 'Control Column Force (FO)',
          'AP (1) Engaged', 'AP (2) Engaged', 'Landing', 'Touchdown'),
     ]
     for combination in combinations:
         self.assertIn(combination, opts, msg=combination)
示例#3
0
    def test_derive(self, value_at_index):
        ap1 = Mock()
        ap2 = Mock()
        phase = Mock()

        pitch_capt = Mock()
        pitch_fo = Mock()
        roll_capt = Mock()
        roll_fo = Mock()

        ap1_eng = Mock()
        ap2_eng = Mock()
        value_at_index.side_effect = [ap1, ap2]

        landings = Mock()
        landings.get_last = Mock()
        landings.get_last.return_value = phase

        touchdowns = Mock()
        touchdowns.get_last = Mock()
        touchdowns.get_last.return_value = Mock()

        pilot = LandingPilot()
        pilot._determine_pilot = Mock()
        pilot._determine_pilot.return_value = Mock()
        pilot.set_flight_attr = Mock()

        pilot.derive(pitch_capt, pitch_fo, roll_capt, roll_fo, ap1_eng,
                ap2_eng, None, None, landings, touchdowns)

        #self.assertTrue(landings.get_last.called)
        #self.assertTrue(touchdowns.get_last.called)

        #pilot._determine_pilot.assert_called_once_with(pitch_capt, pitch_fo,
        #        roll_capt, roll_fo, phase, ap1, ap2, ap3, None, None)

        pilot.set_flight_attr.assert_called_once_with(pilot._determine_pilot.return_value)