From 35bed3b4e6489d3cd305b8f9b7c7b0720c75cda6 Mon Sep 17 00:00:00 2001 From: age Date: Mon, 18 Feb 2008 11:01:44 +0000 Subject: [PATCH] * fixed network unittests * disabled unfinished blockdevice test --- plugins/network/network.py | 3 ++- plugins/network/unittests.py | 9 +++++++++ src/cryptobox/tests/test.core.blockdevice.py | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/network/network.py b/plugins/network/network.py index 4e26331..92cac41 100644 --- a/plugins/network/network.py +++ b/plugins/network/network.py @@ -162,7 +162,8 @@ class network(cryptobox.plugins.base.CryptoBoxPlugin): def get_status(self): """The current IP is the status of this feature. """ - return "%d.%d.%d.%d" % self.__get_current_ip()[1] + #TODO: also return nm & gw for unittests + return "%d.%d.%d.%d" % self.__get_current_ip()[0] diff --git a/plugins/network/unittests.py b/plugins/network/unittests.py index ec88ccf..d58f74e 100644 --- a/plugins/network/unittests.py +++ b/plugins/network/unittests.py @@ -53,6 +53,7 @@ class unittests(WebInterfaceTestClass): self.cmd.submit() ## sleep a little bit longer than the delay necessary for ip-change time.sleep(CHANGE_IP_DELAY + 3) + ## set invalid IPs and check if the original IP stays the same set_ip([1,-2,0,1]) self.assertEquals(orig_ip_text, get_current_ip()) set_ip([1,0,0,256]) @@ -63,9 +64,17 @@ class unittests(WebInterfaceTestClass): new_ip[3] = str((int(orig_ip_octs[3]) + 128) % 256) set_ip(new_ip) self.assertEquals(".".join(new_ip), get_current_ip()) + ## finally restore the original address set_ip(orig_ip_octs) self.assertEquals(orig_ip_text, get_current_ip()) + def test_nm_change(self): + '''Change netmask address.''' + print "ToDo: Implement this!" + + def test_gw_change(self): + '''Change gateway address.''' + print "ToDo: Implement this!" def test_inputs(self): """Check various input patterns for 'network' plugin. diff --git a/src/cryptobox/tests/test.core.blockdevice.py b/src/cryptobox/tests/test.core.blockdevice.py index 003273b..69c99f1 100755 --- a/src/cryptobox/tests/test.core.blockdevice.py +++ b/src/cryptobox/tests/test.core.blockdevice.py @@ -48,13 +48,14 @@ class CoreBlockDevice(CommonTestClass): """ get_device = lambda devname: blockdevice.get_blockdevice(devname) func = lambda parent, child: get_device(parent).is_parent_of(get_device(child)) - func_raw = lambda parent: get_device(parent).is_parent_of + # TODO: + #func_raw = lambda parent: get_device(parent).is_parent_of self.assertTrue(func(self.blockdevice, self.device)) self.assertFalse(func(self.blockdevice, self.blockdevice)) self.assertFalse(func(self.device, self.blockdevice)) self.assertFalse(func(self.device, self.device)) self.assertFalse(func(self.blockdevice, "/dev/hde1")) self.assertFalse(func("ram0", "ram1")) - self.assertFalse(func_raw(self.blockdevice), None)) + #self.assertFalse(func_raw(self.blockdevice) None)) self.assertRaises(CBInternalError, func_raw(self.blockdevice), "")