Skip to content

Commit

Permalink
Tests for Router class.
Browse files Browse the repository at this point in the history
  • Loading branch information
user authored and user committed Dec 12, 2013
1 parent 5c793db commit e50a760
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
1 change: 0 additions & 1 deletion tests/pdu_tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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

Expand Down
39 changes: 39 additions & 0 deletions tests/router_tests.py
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()

0 comments on commit e50a760

Please sign in to comment.