-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
56 lines (36 loc) · 1.56 KB
/
test.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
54
55
56
'''
Created on 3.5.2016
@author: Rohmu
'''
import unittest, os
from io import StringIO
from gameboard import GameBoard
from corrupted_map_file_error import CorruptedMapFileError
class Test(unittest.TestCase):
def testFlawlessMapFile(self):
self.input_file = os.path.join('./Maps/', 'Test Map.txt')
gb = GameBoard()
game = None
try:
game = gb.readMapData(self.input_file)
except CorruptedMapFileError:
self.fail("Loading a correctly structured file caused an exception")
self.assertEqual(gb.name, "Test Map", "Map name not correct")
self.assertEqual(gb.width, 50, "Width not correc")
self.assertEqual(gb.height, 20, "Height not correct")
self.assertEqual(gb.startingLives, 10, "Lives not correct")
self.assertEqual(gb.money, 100, "Money not correct")
self.assertEqual(gb.getTowers(), ["t1", "t2"], "Towers not correct")
self.assertEqual(gb.waves, [[50, ["e1","e2", "e1", "e1", "e1"]], [10, ["e1", "e1", "e2", "e1", "e1"]]], "Waves not correct")
def testWidth(self):
self.input_file = os.path.join('./Test_Files/', 'Wrong Size.txt')
gb = GameBoard()
raised = False
try:
game = gb.readMapData(self.input_file)
except CorruptedMapFileError:
raised = True
self.assertTrue(raised, 'Exception raised')
def testSymbols(self):
if __name__ == '__main__':
unittest.main()