unittests added to some plugins

added "name" tag to all form elements
This commit is contained in:
lars 2006-10-26 12:25:12 +00:00
parent 0a8fc07556
commit 1dc0da0382
23 changed files with 199 additions and 28 deletions

View file

@ -35,7 +35,8 @@ class date(CryptoBoxPlugin.CryptoBoxPlugin):
def getStatus(self):
return str(self.__getCurrentDate())
now = self.__getCurrentDate()
return "%d/%d/%d/%d/%d/%d" % (now.year, now.month, now.day, now.hour, now.minute, now.second)
def __prepareFormData(self):

View file

@ -2,7 +2,7 @@
<h1><?cs var:html_escape(Lang.Plugins.date.Title.ConfigDate) ?></h1>
<?cs call:print_form_header("plugins/date") ?>
<?cs call:print_form_header("set_date", "plugins/date") ?>
<p><label for="date"><?cs var:html_escape(Lang.Plugins.date.Text.Date) ?>: </label><br/>
<select name="day" tabindex="1" size="0"><?cs

View file

@ -29,6 +29,7 @@ if __name__ == "__main__":
proc = subprocess.Popen(
shell = False,
stdout = subprocess.PIPE,
args = [DATE_BIN, args[0]])
proc.communicate()
sys.exit(proc.returncode)

View file

@ -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()