-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_planets.py
More file actions
45 lines (34 loc) · 1.14 KB
/
Copy pathtest_planets.py
File metadata and controls
45 lines (34 loc) · 1.14 KB
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
#!/usr/env/python
# Test class for Planets class for Galaxy
# Author: matt.j.bernhardt@gmail.com
# Version: 0.1
# Modules
import unittest
from planets import Planet
# Variables
# Classes
# See http://pythontesting.net/framework/unittest/unittest-introduction/
class TestPlanet(unittest.TestCase):
def setUp(self):
self.planet = Planet('A', 'Foo', 0, 0, 10)
def test_BuildShips(self):
Planet.BuildShips(self.planet)
self.assertEqual(self.planet.ships, 10)
def test_SetOwner(self):
Planet.SetOwner(self.planet, 'Fubar')
self.assertEqual(self.planet.owner, 'Fubar')
def test_AddShips(self):
Planet.AddShips(self.planet, 5)
self.assertEqual(self.planet.ships, 5)
Planet.AddShips(self.planet, 10)
self.assertEqual(self.planet.ships, 15)
def test_RemoveShips(self):
Planet.AddShips(self.planet, 20)
self.assertEqual(self.planet.ships, 20)
Planet.RemoveShips(self.planet, 5)
self.assertEqual(self.planet.ships, 15)
# Test removing more ships than present on planet.
Planet.RemoveShips(self.planet, 20)
self.assertEqual(self.planet.ships, 0)
if __name__ == "__main__":
unittest.main()