-
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.
- Loading branch information
user
authored and
user
committed
Dec 12, 2013
1 parent
5c793db
commit e50a760
Showing
2 changed files
with
39 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
sys.path.append("/home/user/_cluster/cntrl_hac") | ||
sys.path.append("/home/user/_cluster/testutil_hac") | ||
from exceptionz import DeviceError | ||
from router import Router | ||
|
||
import unittest | ||
|
||
|
||
# Working router. | ||
ROUTER_IP = "192.168.50.174" | ||
# Some device connected to router. | ||
DUMMY_DEVICE = Router("dummy", {"ip": None}) | ||
DUMMY_DEVICE_PORT = 13 | ||
|
||
|
||
class TestsForRouter(unittest.TestCase): | ||
def test_correct_settings(self): | ||
router = Router("my_router", {"ip": ROUTER_IP, | ||
"port%i" % (DUMMY_DEVICE_PORT): DUMMY_DEVICE.id}) | ||
router.disable_port(DUMMY_DEVICE) | ||
router.enable_port(DUMMY_DEVICE) | ||
|
||
|
||
def test_wrong_ip(self): | ||
router = Router("my_router", {"ip": "127.0.0.1", | ||
"port%i" % (DUMMY_DEVICE_PORT): DUMMY_DEVICE.id}) | ||
with self.assertRaises(DeviceError): | ||
router.disable_port(DUMMY_DEVICE) | ||
|
||
|
||
def test_wrong_ports_config(self): | ||
router = Router("my_router", {"ip": ROUTER_IP}) | ||
with self.assertRaises(DeviceError): | ||
router.disable_port(DUMMY_DEVICE) | ||
|
||
|
||
if (__name__ == '__main__'): | ||
unittest.main() |