cryptonas-branches/pythonrewrite/plugins/network/unittests.py
lars 80337411ae URLs changed to new plugin addressing scheme
svn:keywords set
fixed: shutdown - delay reboot/poweroff by some seconds to finish the web page before
added: format_fs - show link to umount in case of active device
added: new plugin "language_selection"
fixed: recently introduced syntax error in 'network'
added: "volume_props" mentions encryption support via "format_fs" (including link)
updated: plugin-interface.txt
fixed: broken test case for date plugin (caused by twill, I guess)
added: "partition" plugin - better handling of config partition
2006-11-06 06:17:22 +00:00

46 lines
1.5 KiB
Python

import WebInterfaceTestClass
from network import CHANGE_IP_DELAY
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_ip_change(self):
'''change of network address'''
## the time module is necessary for the CHANGE_IP_DELAY
import time
self.register_auth(self.URL + "network")
self.cmd.go(self.URL + "network")
## extract the current IP from the network plugin output
def getCurrentIP():
self.cmd.go(self.URL + "network")
self.cmd.show()
self.cmd.find(u'Data.Status.Plugins.network=([0-9\.]*)$', "m")
return self.locals["__match__"]
origIPtext = getCurrentIP()
origIPocts = origIPtext.split(".")
## check, if the original IP is valid (contains four octets)
self.assertEquals(4, len(origIPocts))
self.cmd.echo(origIPocts)
wrongIP = "192.168.123.321"
def setIP((ip1, ip2, ip3, ip4)):
self.cmd.go(self.URL + "network")
self.cmd.formvalue("set_ip", "ip1", str(ip1))
self.cmd.formvalue("set_ip", "ip2", str(ip2))
self.cmd.formvalue("set_ip", "ip3", str(ip3))
self.cmd.formvalue("set_ip", "ip4", str(ip4))
self.cmd.submit()
## sleep a little bit longer than the delay necessary for ip-change
time.sleep(CHANGE_IP_DELAY + 0.2)
setIP([1,-2,0,1])
self.assertEquals(origIPtext, getCurrentIP())
setIP([1,0,0,256])
self.assertEquals(origIPtext, getCurrentIP())
setIP([1,"foo",0,1])
self.assertEquals(origIPtext, getCurrentIP())
setIP([10,12,0,2])
self.assertEquals("10.12.0.2", getCurrentIP())
setIP(origIPocts)
self.assertEquals(origIPtext, getCurrentIP())