cryptonas-branches/pythonrewrite/plugins/date/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

61 lines
2 KiB
Python

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 + "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):
"""for now we have to use this function instead of the one below"""
date_url = self.URL + "date?store=1&year=%d&month=%d&day=%d&hour=%d&minute=%d" % (date["year"], date["month"], date["day"], date["hour"], date["minute"])
self.register_auth(date_url)
self.cmd.go(date_url)
def _setDateBroken(self, date):
"""this should work, but the parsing of twill seems to be broken"""
date_url = self.URL + "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()