-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now PDU and Router classes can raise exceptions + tests for PDU class.
- Loading branch information
user
authored and
user
committed
Dec 12, 2013
1 parent
fbbb58d
commit 5c793db
Showing
4 changed files
with
63 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import sys | ||
sys.path.append("/home/user/_cluster/cntrl_hac") | ||
sys.path.append("/home/user/_cluster/testutil_hac") | ||
from cluster import Cluster | ||
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() |