parent
0a8fc07556
commit
1dc0da0382
@ -0,0 +1,52 @@
|
||||
import WebInterfaceTestClass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_get_date(self):
|
||||
date = self._getCurrentDate()
|
||||
|
||||
|
||||
def test_change_date(self):
|
||||
now = self._getCurrentDate()
|
||||
## copy current time
|
||||
new_date = dict(now)
|
||||
## move three minutes forward (more is not nice because of screensavers)
|
||||
new_date["minute"] = (now["minute"] + 3) % 60
|
||||
## in case of minute-overflow we also have to move the hour a little bit forward
|
||||
new_date["hour"] = now["hour"] + ((now["minute"] + 3) / 60)
|
||||
## move forward ...
|
||||
self._setDate(new_date)
|
||||
self.assertEquals(new_date, self._getCurrentDate())
|
||||
## ... and backward
|
||||
self._setDate(now)
|
||||
self.assertEquals(now, self._getCurrentDate())
|
||||
|
||||
|
||||
def _getCurrentDate(self):
|
||||
date_url = self.URL + "plugins/date"
|
||||
self.register_auth(date_url)
|
||||
self.cmd.go(date_url)
|
||||
self.cmd.find("Data.Status.Plugins.date=([0-9]+/[0-9]+/[0-9]+/[0-9]+/[0-9]+/[0-9]+)$", "m")
|
||||
dateNumbers = self.locals["__match__"].split("/")
|
||||
self.assertEquals(len(dateNumbers), 6)
|
||||
## we ignore seconds
|
||||
dateField = {
|
||||
"year" : int(dateNumbers[0]),
|
||||
"month" : int(dateNumbers[1]),
|
||||
"day" : int(dateNumbers[2]),
|
||||
"hour" : int(dateNumbers[3]),
|
||||
"minute" : int(dateNumbers[4])}
|
||||
return dateField
|
||||
|
||||
|
||||
def _setDate(self, date):
|
||||
date_url = self.URL + "plugins/date"
|
||||
self.register_auth(date_url)
|
||||
self.cmd.go(date_url)
|
||||
self.cmd.formvalue("set_date", "year", str(date["year"]))
|
||||
self.cmd.formvalue("set_date", "month", str(date["month"]))
|
||||
self.cmd.formvalue("set_date", "day", str(date["day"]))
|
||||
self.cmd.formvalue("set_date", "hour", str(date["hour"]))
|
||||
self.cmd.formvalue("set_date", "minute", str(date["minute"]))
|
||||
self.cmd.submit()
|
||||
|
@ -0,0 +1,21 @@
|
||||
import WebInterfaceTestClass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_logs(self):
|
||||
log_url = self.URL + "plugins/logs"
|
||||
self.register_auth(log_url)
|
||||
self.cmd.go(log_url)
|
||||
self.cmd.find('class="console"')
|
||||
|
||||
def test_write_logs(self):
|
||||
## we have to assume two things:
|
||||
## 1) log level is at least "error"
|
||||
## 2) the log message does not get lost in a possible stream of log messages
|
||||
log_text = "unittest - just a marker - please ignore"
|
||||
self.cbox.log.error(log_text)
|
||||
log_url = self.URL + "plugins/logs"
|
||||
self.register_auth(log_url)
|
||||
self.cmd.go(log_url)
|
||||
self.cmd.find(log_text)
|
||||
|
@ -0,0 +1,45 @@
|
||||
import WebInterfaceTestClass
|
||||
from network import CHANGE_IP_DELAY
|
||||
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def atest_ip_change(self):
|
||||
'''change of network address'''
|
||||
## the time module is necessary for the CHANGE_IP_DELAY
|
||||
import time
|
||||
self.register_auth(self.URL + "plugins/network")
|
||||
self.cmd.go(self.URL + "plugins/network")
|
||||
## extract the current IP from the network plugin output
|
||||
def getCurrentIP():
|
||||
self.cmd.go(self.URL + "plugins/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 + "plugins/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())
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
import WebInterfaceTestClass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "plugins/shutdown"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
self.cmd.find('<form name="shutdown"')
|
||||
self.cmd.find('<form name="reboot"')
|
||||
|
@ -0,0 +1,27 @@
|
||||
import WebInterfaceTestClass
|
||||
|
||||
## this user may not be removed
|
||||
from user_manager import RESERVED_USERS
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_users(self):
|
||||
print self._getUsers()
|
||||
#self.cmd.showforms()
|
||||
|
||||
|
||||
def _addUser(self, user, password):
|
||||
self._gotPage()
|
||||
## TODO: finish
|
||||
|
||||
|
||||
def _gotoPage(self):
|
||||
url = self.URL + "plugins/user_manager"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
|
||||
|
||||
def _getUsers(self):
|
||||
self._gotoPage()
|
||||
self.cmd.find("Data.Status.Plugins.user_manager=([\w/]+)")
|
||||
return self.locals["__match__"].split("/")
|
Loading…
Reference in New Issue