-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindown_test.py
72 lines (55 loc) · 2.03 KB
/
windown_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import unittest
from datetime import datetime
from unittest.mock import MagicMock
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import Qt
import operations
from windown import Window
app = QApplication([])
class TestWindow(unittest.TestCase):
def setUp(self):
self.window = Window()
def test_creation(self):
self.assertIsInstance(self.window, Window)
def test_hour_plus(self):
self.window.hour = 0
self.window.hour_plus()
self.assertEqual(self.window.hour, 1)
self.window.hour = 23
self.window.hour_plus()
self.assertEqual(self.window.hour, 23)
def test_hour_minus(self):
self.window.hour = 1
self.window.hour_minus()
self.assertEqual(self.window.hour, 0)
self.window.hour = 0
self.window.hour_minus()
self.assertEqual(self.window.hour, 0)
def test_min_plus(self):
self.window.minute = 0
self.window.min_plus()
self.assertEqual(self.window.minute, 1)
self.window.minute = 59
self.window.min_plus()
self.assertEqual(self.window.minute, 59)
def test_min_minus(self):
self.window.minute = 1
self.window.min_minus()
self.assertEqual(self.window.minute, 0)
self.window.minute = 0
self.window.min_minus()
self.assertEqual(self.window.minute, 0)
def test_reset_time(self):
self.window.hour = 1
self.window.minute = 1
self.window.reset_time()
self.assertEqual(self.window.hour, int(datetime.now().strftime("%H")))
self.assertEqual(self.window.minute, int(datetime.now().strftime("%M")))
def test_request_shutdown(self):
self.window.hour = int(datetime.now().strftime("%H")) + 1
self.window.minute = int(datetime.now().strftime("%M"))
self.window.request_shutdown()
def test_request_shutdown(self):
self.window.cancel_shutdown()
if __name__ == '__main__':
unittest.main()