Beispiel #1
0
class TestAiport(unittest.TestCase):

    def setUp(self):
        self.airport = Airport()

    def tearDown(self):
        pass

    def test_Airport_exists(self):
        self.assertEqual(self.airport, self.airport)

    def test_Airport_stores_planes(self):
        self.assertEqual(self.airport.planes, [])

    def test_Airport_confirms_plane_landed(self):
        self.assertEqual(self.airport.land("plane"), "plane has landed")

    def test_Airport_lands_plane_and_stores_it_in_planes(self):
        self.airport.land("plane")
        self.assertEqual(self.airport.planes, ["plane"])

    def test_Airport_instructs_plane_to_take_off(self):
        self.airport.land("plane")
        self.airport.takeoff("plane")
        self.assertEqual(self.airport.planes, [])

    def test_Airport_instructs_plane_to_take_off(self):
        self.airport.land("plane")
        self.assertEqual(self.airport.takeoff("plane"), "plane has taken off")

    def test_Airport
Beispiel #2
0
class TestUserStory(unittest.TestCase):
    def setUp(self):
        self.airport = Airport()
        self.plane = Plane()

    def test_instructing_a_plane_to_land_should_land_it(self):
        # As an air traffic controller
        # So I can get passengers to a destination
        # I want to instruct a plane to land at an airport and confirm that it has landed
        self.airport.instruct_to_land(self.plane)
        self.assertIn(self.plane, self.airport.planes)
        self.assertFalse(self.plane.isflying)

    def test_instructing_a_plane_to_take_off_should_take_it_off(self):
        # As an air traffic controller
        # So I can get passengers on the way to their destination
        # I want to instruct a plane to take off from an airport and confirm that it is no longer in the airport
        self.airport.instruct_to_land(self.plane)
        self.airport.instruct_to_take_off(self.plane)
        self.assertNotIn(self.plane, self.airport.planes)
        self.assertTrue(self.plane.isflying)
class TestUserStory(unittest.TestCase):

    def setUp(self):
        self.airport = Airport()
        self.plane = Plane()

    def test_instructing_a_plane_to_land_should_land_it(self):
        # As an air traffic controller
        # So I can get passengers to a destination
        # I want to instruct a plane to land at an airport and confirm that it has landed
        self.airport.instruct_to_land(self.plane)
        self.assertIn(self.plane, self.airport.planes)
        self.assertFalse(self.plane.isflying)

    def test_instructing_a_plane_to_take_off_should_take_it_off(self):
        # As an air traffic controller
        # So I can get passengers on the way to their destination
        # I want to instruct a plane to take off from an airport and confirm that it is no longer in the airport
        self.airport.instruct_to_land(self.plane)
        self.airport.instruct_to_take_off(self.plane)
        self.assertNotIn(self.plane, self.airport.planes)
        self.assertTrue(self.plane.isflying)
Beispiel #4
0
 def setUp(self):
     self.airport = Airport()
     self.plane = Plane()
Beispiel #5
0
 def setUp(self):
     self.airport = Airport()
 def setUp(self):
     self.airport = Airport()
     self.plane = Plane()
Beispiel #7
0
 def setUp(self):
     self.airport = Airport()
     self.plane = Mock()
Beispiel #8
0
class TestAirport(unittest.TestCase):

    def setUp(self):
        self.airport = Airport()
        self.plane = Mock()

    def test_airport_initializes_with_empty_planes_array(self):
        self.assertEqual(self.airport.planes, [])

    def test_instruct_to_land_sockets_plane_in_planes(self):
        self.airport.instruct_to_land(self.plane)
        self.assertIn(self.plane, self.airport.planes)

    def test_instruct_to_land_calls_land_on_plane(self):
        self.airport.instruct_to_land(self.plane)
        self.plane.land.assert_called_with()

    def test_instruct_to_take_off_removes_plane_from_planes(self):
        self.airport.instruct_to_land(self.plane)
        self.airport.instruct_to_take_off(self.plane)
        self.assertNotIn(self.plane, self.airport.planes)

    def test_instruct_to_take_off_calls_take_off_on_plane(self):
        self.airport.instruct_to_land(self.plane)
        self.airport.instruct_to_take_off(self.plane)
        self.plane.take_off.assert_called_with()

    def test_instruct_to_take_off_should_fail_if_plane_not_at_airport(self):
        with self.assertRaisesRegexp(Exception, 'Plane is not at this airport'):
            self.airport.instruct_to_take_off(self.plane)