forked from jonathansayer/airport_challenge_python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
airport_unittest.py
53 lines (43 loc) · 1.45 KB
/
airport_unittest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import unittest
from mock import Mock
from airport import Airport
class AirportTest(unittest.TestCase):
def test(self):
self.assertTrue(True)
def test_airport_capacity(self):
airport = Airport()
self.assertEqual(airport.capacity,20)
def test_airport_land_plane(self):
airport = Airport()
plane = Mock()
airport.land_plane(plane)
plane.land.assert_called_once_with()
def test_airport_storing_planes(self):
airport = Airport()
plane = Mock()
airport.land_plane(plane)
self.assertEqual(airport.planes,[plane])
def test_airport_take_off_plane(self):
airport = Airport()
plane = Mock()
weather = Mock()
weather.stormy.return_value = False
airport.planes = [plane]
airport.release_plane(plane,weather)
plane.take_off.assert_called_once_with()
def test_airport_release_plane(self):
airport = Airport()
plane = Mock()
weather = Mock()
weather.stormy.return_value = False
airport.land_plane(plane)
airport.release_plane(plane,weather)
self.assertEqual(airport.planes,[])
def test_stormy_weather(self):
airport = Airport()
plane = Mock()
weather = Mock(stormy=True)
airport.planes = [plane]
self.assertEqual(airport.release_plane(plane,weather), "Weather is Stormy")
if __name__ == '__main__':
unittest.main()