-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathguitests.py
More file actions
58 lines (50 loc) · 1.76 KB
/
guitests.py
File metadata and controls
58 lines (50 loc) · 1.76 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
46
47
48
49
50
51
52
53
54
55
56
57
58
import unittest
from tkinter import *
from gui import Gui
import config
import moving
class GuiTests(unittest.TestCase):
def setUp(self):
self.root = Tk()
self.gui = Gui(self.root)
ball = moving.Ball()
paddleL = moving.PaddleL()
paddleR = moving.PaddleR()
self.items = {
'ball': ball,
'paddleL': paddleL,
'paddleR': paddleR,
}
for name, item in self.items.items():
self.gui.addItem(name, item.getCoords())
def testGuiHasBoard(self):
self.gui.board
def testBoardCorrectSize(self):
self.assertEqual(int(self.gui.board.cget('width')),
config.BOARD_WIDTH)
self.assertEqual(int(self.gui.board.cget('height')),
config.BOARD_HEIGHT)
def testGuiHasItems(self):
for name in self.items:
self.assertTrue(name in self.gui.items)
def testMoveMakesNewItem(self):
testitem = 'testitem'
self.gui.move(testitem, (20, 20, 30, 30))
self.assertTrue(self.gui.items[testitem])
def testMoveMoves(self):
self.gui.move('ball',
self.items['ball'].getCoords())
start = self.gui.items['ball'].coords
self.items['ball'].move()
self.gui.move('ball',
self.items['ball'].getCoords())
end = self.gui.items['ball'].coords
self.assertNotEqual(start, end)
def testNoMove(self):
self.gui.move('ball',
self.items['ball'].getCoords())
start = self.gui.items['ball'].coords
self.gui.move('ball',
self.items['ball'].getCoords())
end = self.gui.items['ball'].coords
self.assertEqual(start, end)