-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdu_tests.py
39 lines (28 loc) · 1.02 KB
/
pdu_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
import sys
sys.path.append("/home/user/_cluster/cntrl_hac")
sys.path.append("/home/user/_cluster/testutil_hac")
from exceptionz import DeviceError
from pdu import PDU
import unittest
# Working PDU.
PDU_IP = "192.168.50.110"
# Some device connected to PDU.
DUMMY_DEVICE = PDU("dummy", {"ip": None})
DUMMY_DEVICE_OUTLET = 8
class TestsForPDU(unittest.TestCase):
def test_correct_settings(self):
pdu = PDU("my_pdu", {"ip": PDU_IP,
"outlet%i" % (DUMMY_DEVICE_OUTLET): DUMMY_DEVICE.id})
pdu.off(DUMMY_DEVICE)
pdu.on(DUMMY_DEVICE)
def test_wrong_ip(self):
pdu = PDU("my_pdu", {"ip": "127.0.0.1",
"outlet%i" % (DUMMY_DEVICE_OUTLET): DUMMY_DEVICE.id})
with self.assertRaises(DeviceError):
pdu.off(DUMMY_DEVICE)
def test_wrong_outlets_config(self):
pdu = PDU("my_pdu", {"ip": PDU_IP})
with self.assertRaises(DeviceError):
pdu.off(DUMMY_DEVICE)
if (__name__ == '__main__'):
unittest.main()