* fixed network unittests

* disabled unfinished blockdevice test
This commit is contained in:
age 2008-02-18 11:01:44 +00:00
parent eaf37a872a
commit 35bed3b4e6
3 changed files with 14 additions and 3 deletions

View file

@ -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]

View file

@ -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.

View file

@ -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), "")