Ejemplo n.º 1
0
class TestCasePlane(unittest.TestCase):
    def setUp(self):
        self.plane = Plane()

    def test_construction(self):
        self.assertNotEqual(self.plane,
                            None,
                            msg='Error occurred while creating the plane.')

    def test_information(self):
        to_string = self.plane.__str__()
        self.assertIsInstance(to_string, str,
                              'Plane does not convert to string.')

    def test_init_tilt(self):
        new_plane = Plane()
        self.assertEqual(new_plane.angle, 0,
                         'Plane tilt angle is not initialize with 0.')

    def test_tilt_changing(self):
        tilt = self.plane.angle
        Turbulance.flight_impact(self.plane)
        self.assertNotEqual(
            tilt,
            self.plane.angle,
            msg='Error - turbulence did not change plane angle.')

    def test_setting_angle(self):
        self.plane.set_angle(-2)
        self.assertEqual(self.plane.angle, -2,
                         'Setting tilt angle does not work.')

    def test_correction(self):
        Turbulance.flight_impact(self.plane)
        Correction.flight_impact(self.plane)
        self.assertEqual(self.plane.angle, 0,
                         'Correction after turbulance was not fixed.')

    def test_correction_with_positive_angle(self):
        self.plane.set_angle(2)
        Correction.flight_impact(self.plane)
        self.assertEqual(self.plane.angle, 0,
                         'Correction with positive value was not fixed.')

    def test_correction_with_negative_angle(self):
        self.plane.set_angle(-2)
        Correction.flight_impact(self.plane)
        self.assertEqual(self.plane.angle, 0,
                         'Correction with negative value was not fixed.')

    def test_taking_off(self):
        self.plane.take_off()
        self.assertEqual(self.plane.is_flying, True, 'Plane did not take off.')

    def test_landing(self):
        self.plane.land()
        self.assertEqual(self.plane.is_flying, False, 'Plane did not land.')