-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtests.py
96 lines (73 loc) · 3.27 KB
/
tests.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import unittest
from mock import Mock
from pyhwtherm import PyHWTherm
class TestPyHWTherm(unittest.TestCase):
def setUp(self):
self.username = 'user'
self.password = 'pass'
self.deviceid = 123456
self.testtherm = PyHWTherm(self.username,self.password,self.deviceid)
def testCreateObject(self):
self.testtherm = PyHWTherm(
self.username,
self.password,
self.deviceid
)
self.assertIsInstance(self.testtherm,PyHWTherm)
def testGetUTC(self):
self.assertIsInstance(self.testtherm.getUTC(),str)
def testPermBlank(self):
prep = {
"SystemSwitch": None,
"HeatSetpoint": None,
"CoolSetpoint": None,
"HeatNextPeriod": None,
"CoolNextPeriod": None,
"StatusHeat": None,
"StatusCool": None,
"FanMode": None,
"DeviceID": self.deviceid
}
self.testtherm.permHold()
self.assertEqual(self.testtherm.change_request,prep)
#self.assertEqual(self.testtherm['DeviceID'],self.deviceid)
def testPermHeat71(self):
self.testtherm.permHold(heat=71)
self.assertEqual(self.testtherm.change_request["HeatSetpoint"],71)
self.assertEqual(self.testtherm.change_request["CoolSetpoint"],None)
def testPermHeat10Cool50(self):
self.testtherm.permHold(heat=10,cool=50)
self.assertEqual(self.testtherm.change_request["HeatSetpoint"],10)
self.assertEqual(self.testtherm.change_request["CoolSetpoint"],50)
def testPermCool90(self):
self.testtherm.permHold(cool=90)
self.assertEqual(self.testtherm.change_request["HeatSetpoint"],None)
self.assertEqual(self.testtherm.change_request["CoolSetpoint"],90)
def testTempTime(self):
self.testtherm.tempHold("01:30")
self.assertEqual(self.testtherm.change_request["CoolNextPeriod"],6)
self.assertEqual(self.testtherm.change_request["HeatNextPeriod"],6)
def testFanOn(self):
self.testtherm.fan("on")
self.assertEqual(self.testtherm.change_request["FanMode"],PyHWTherm.FANON)
def testFanAuto(self):
self.testtherm.fan("auto")
self.assertEqual(self.testtherm.change_request["FanMode"],PyHWTherm.FANAUTO)
def testFanBad(self):
self.assertEqual(self.testtherm.fan('durr'),False)
def testSystemAuto(self):
self.testtherm.systemState("auto")
self.assertEqual(self.testtherm.change_request["SystemSwitch"],PyHWTherm.SYSTEMAUTO)
def testSystemCool(self):
self.testtherm.systemState("cool")
self.assertEqual(self.testtherm.change_request["SystemSwitch"],PyHWTherm.SYSTEMCOOL)
def testSystemHeat(self):
self.testtherm.systemState("heat")
self.assertEqual(self.testtherm.change_request["SystemSwitch"],PyHWTherm.SYSTEMHEAT)
def testSystemOff(self):
self.testtherm.systemState("off")
self.assertEqual(self.testtherm.change_request["SystemSwitch"],PyHWTherm.SYSTEMOFF)
def testSystemBad(self):
self.assertEqual(self.testtherm.systemState('durr'),False)
if __name__ == '__main__':
unittest.main()