added some basic unittests

changed warning/success message system to a new style
unified design of "hints" in form interfaces
fixed small bugs in "network" and "partition" plugin interfaces
"partition" and "disks" plugins: show blockdevice size during device selection
german translation for "disks" plugin added
This commit is contained in:
lars 2006-11-02 14:01:09 +00:00
parent 29d2e442f2
commit c35e204a7b
34 changed files with 197 additions and 57 deletions

View File

@ -2,6 +2,8 @@
<h1><?cs var:html_escape(Lang.Plugins.date.Title.ConfigDate) ?></h1>
<?cs call:handle_messages() ?>
<?cs call:print_form_header("set_date", "plugins/date") ?>
<p><label for="date"><?cs var:html_escape(Lang.Plugins.date.Text.Date) ?>: </label><br/>

View File

@ -2,10 +2,12 @@
<h1><?cs var:html_escape(Lang.Plugins.disks.Title.Disks) ?></h1>
<?cs call:handle_messages() ?>
<?cs # TODO: add no-disks-available warning ?>
<?cs if:subcount(Data.Disks) == 0 ?>
NO DISKS
<?cs call:hint(Lang.Plugins.disks.Text.NoDisksAvailable) ?>
<?cs else ?>
<?cs # we use "loop" instead of "each" to keep the order of the disks ?>
<?cs loop: index = #0, subcount(Data.Disks)-1, #1 ?>

View File

@ -0,0 +1,6 @@
Name = Datenträger-Übersicht
Link = Datenträger
Title.Disks = Verfügbare Datenträger
Text.NoDisksAvailable = Es sind keine Datenträger verfügbar!

View File

@ -3,3 +3,4 @@ Link = Disks
Title.Disks = Available disks
Text.NoDisksAvailable = No available disks were found!

View File

@ -0,0 +1,9 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
'''display all devices'''
self.cmd.go(self.URL + "plugins/disks?weblang=en")
self.cmd.find("Disks")

View File

@ -0,0 +1,10 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
url = self.URL + "plugins/format_fs?weblang=en&device=%2Fdev%2Floop1"
self.register_auth(url)
self.cmd.go(url)
self.cmd.find('Initializing filesystem')

View File

@ -4,28 +4,29 @@
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
<?cs call:handle_messages() ?>
<?cs if:Data.CurrentDisk.active ?>
<div class="unavailable_action">
<?cs var:html_escape(Lang.Plugins.format_fs.Text.UnmountBeforeInit) ?>
</div>
<?cs call:hint(Lang.Plugins.format_fs.Text.UnmountBeforeInit) ?>
<?cs else ?>
<?cs call:print_form_header("set_type", "plugins/format_fs") ?>
<?cs call:hint(Lang.Plugins.format_fs.Text.FormatWarning) ?>
<p><label for="fs_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType)
?>: </label><select name="fs_type" id="fs_type" size="0" ?>
?>: </label><select name="fs_type" id="fs_type" size="0">
<?cs each:x = Data.Plugins.format_fs.fs_types ?>
<option <?cs if:x == "windows" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(x) ?></option><?cs /each ?>
</select></p>
<p><label for="container_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.IsEncrypted)
?>: <select name="container_type" id="container_type">
<option value="luks" <?cs if:Data.Plugins.format_fs.container_type != "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?></option> -->
?>: </label><select name="container_type" id="container_type">
<option value="luks" <?cs if:Data.Plugins.format_fs.container_type != "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?></option>
<option value="plain" <?cs if:Data.Plugins.format_fs.container_type == "plain" ?>selected="selected"<?cs /if ?>><?cs var:html_escape(Lang.Plugins.format_fs.Text.No) ?></option>
</select></p>
<p class="note"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FormatWarning) ?></p>
<p><input type="checkbox" name="confirm" value="1" id="confirm"><label for="confirm"><?cs var:html_escape(Lang.Plugins.format_fs.Text.Confirm) ?><p/>
<p><input type="checkbox" name="confirm" value="1" id="confirm" /><label for="confirm"><?cs var:html_escape(Lang.Plugins.format_fs.Text.Confirm) ?></label></p>
<input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
<input type="hidden" name="store" value="step1" />

View File

@ -4,15 +4,15 @@
<h2><?cs var:html_escape(Lang.Plugins.format_fs.Title.Format) ?></h2>
<?cs call:handle_messages() ?>
<?cs if:Data.CurrentDisk.active ?>
<div class="unavailable_action">
<?cs var:html_escape(Lang.Plugins.format_fs.Text.UnmountBeforeInit) ?>
</div>
<?cs call:hint(Lang.Plugins.format_fs.Text.UnmountBeforeInit) ?>
<?cs else ?>
<?cs call:print_form_header("set_luks", "plugins/format_fs") ?>
<p class="note"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FormatWarning) ?></p>
<?cs call:hint(Lang.Plugins.format_fs.Text.FormatWarning) ?>
<p><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType) ?>: <?cs var:html_escape(Data.Plugins.format_fs.fs_type) ?></p>
<p><?cs var:html_escape(Lang.Plugins.format_fs.Text.IsEncrypted) ?>: <?cs if:Data.Plugins.format_fs.container_type == "luks" ?><?cs

View File

@ -2,6 +2,8 @@
<div id="doc">
<?cs call:handle_messages() ?>
<?cs include:Settings.DocDir + '/' + Settings.Language + '/' + Data.Plugins.help.Page + '.html' ?>
</div>

View File

@ -0,0 +1,29 @@
import WebInterfaceTestClass
from twill.errors import *
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_help_pages(self):
'''help pages should be available in different languages'''
## check english help pages
self.cmd.go(self.URL + "plugins/help?weblang=en")
self.cmd.find("Table of Contents")
self.cmd.find("Getting started")
self.cmd.go(self.URL + "plugins/help?weblang=de")
self.cmd.find("Table of Contents")
self.cmd.find("Wie geht es los")
self.cmd.go(self.URL + "plugins/help?weblang=si")
self.assertRaises(TwillAssertionError, self.cmd.notfind, "Table of Contents")
#TODO: add a slovene text here, as soon as the help is translated
self.cmd.go(self.URL + "plugins/help?weblang=fr")
self.assertRaises(TwillAssertionError, self.cmd.notfind, "Table of Contents")
#TODO: add a french text here, as soon as the help is translated
## test a random language - it should fall back to english
self.cmd.go(self.URL + "plugins/help?weblang=foobar")
self.assertRaises(TwillAssertionError, self.cmd.notfind, "Table of Contents")

View File

@ -8,6 +8,8 @@
<h1><?cs var:html_escape(Lang.Plugins.logs.Title.Log) ?></h1>
<?cs call:handle_messages() ?>
<?cs if:Data.Plugins.logs.Content ?>
<p class="console"><?cs var:Data.Plugins.logs.Content ?></p>
<?cs else ?>

View File

@ -6,6 +6,8 @@
<h1><?cs var:html_escape(Lang.Plugins.network.Title.Network) ?></h1>
<?cs call:handle_messages() ?>
<?cs call:print_form_header("set_ip", "plugins/network") ?>
<p><label for="ip"><?cs var:html_escape(Lang.Plugins.network.Text.IP) ?>: </label>
@ -24,3 +26,5 @@
</form>
<?cs call:help_link("CryptoBoxUserConfiguration") ?>

View File

@ -30,7 +30,8 @@ class network(CryptoBoxPlugin.CryptoBoxPlugin):
ip = "%d.%d.%d.%d" % (int(ip1), int(ip2), int(ip3), int(ip4))
except ValueError:
self.hdf["Data.Warning"] = "Plugins.network.InvalidIP"
return None
self.__prepareFormData()
return "form_network"
if self.__setIP(ip):
self.cbox.log.info("the IP was successfully changed: %s" % ip)
self.hdf["Data.Success"] = "Plugins.network.IPChanged"

View File

@ -4,7 +4,7 @@ from network import CHANGE_IP_DELAY
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def atest_ip_change(self):
def test_ip_change(self):
'''change of network address'''
## the time module is necessary for the CHANGE_IP_DELAY
import time

View File

@ -95,12 +95,14 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
def __actionSelectDevice(self, args):
import CryptoBoxTools
block_devices = [e
for e in CryptoBoxTools.getParentBlockDevices()
if self.cbox.isDeviceAllowed(e)]
counter = 0
for a in block_devices:
self.hdf[self.hdf_prefix + "BlockDevices.%d" % counter] = a
self.hdf[self.hdf_prefix + "BlockDevices.%d.name" % counter] = a
self.hdf[self.hdf_prefix + "BlockDevices.%d.size" % counter] = CryptoBoxTools.getBlockDeviceSizeHumanly(a)
self.cbox.log.debug("found a suitable block device: %s" % a)
counter += 1
if self.withConfigPartition:
@ -241,22 +243,12 @@ class partition(CryptoBoxPlugin.CryptoBoxPlugin):
def __getAvailableDeviceSize(self, device):
"""calculate the available size (MB) of the device
also consider a (possible) configuration partition"""
if not device: return 0
rdev = os.stat(device).st_rdev
minor = os.minor(rdev)
major = os.major(rdev)
for f in file("/proc/partitions"):
try:
elements = f.split()
if len(elements) != 4: continue
if (int(elements[0]) == major) and (int(elements[1]) == minor):
deviceSize = int(elements[2])/1024
import CryptoBoxTools
deviceSize = CryptoBoxTools.getBlockDeviceSize(device)
if deviceSize < 0: return 0
if self.withConfigPartition:
deviceSize -= self.ConfigPartition["size"]
return deviceSize
except ValueError:
pass
return 0
def __isWithConfigPartition(self, args):

View File

@ -4,14 +4,19 @@
<h1><?cs var:html_escape(Lang.Plugins.partition.Title.Partition) ?></h1>
<?cs call:handle_messages() ?>
<?cs if:subcount(Data.Plugins.partition.BlockDevices) > 0 ?>
<?cs call:print_form_header("select_device", "plugins/partition") ?>
<?cs call:hint(Lang.Plugins.partition.Text.WarningMessage) ?>
<p><label for="block_device"><?cs var:html_escape(Lang.Plugins.partition.Text.SelectDevice) ?>: </label><br/>
<select name="block_device" id="block_device" tabindex="1" size="0">
<?cs each:x = Data.Plugins.partition.BlockDevices
?><option><?cs var:html_escape(x) ?></option>
?><option value="<?cs var:html_escape(x.name) ?>"><?cs
var:html_escape(x.name) ?> (<?cs var:html_escape(x.size) ?>)</option>
<?cs /each ?>
</select></p>
@ -22,10 +27,6 @@
<?cs /if ?>
-->
<p class="note">
<?cs var:html_escape(Lang.Plugins.partition.Text.WarningMessage) ?>
</p>
<input type="hidden" name="step" value="add_partition" />
<div align="center"><table><tr>

View File

@ -4,14 +4,19 @@
<h1><?cs var:html_escape(Lang.Plugins.partition.Title.Partition) ?></h1>
<?cs call:handle_messages() ?>
<div align="center">
<table class="partition">
<?cs if:Data.Plugins.partition.availSize > 0 ?>
<?cs # no table header if the harddisk is not partitionable (e.g. still active) ?>
<tr>
<th><?cs var:html_escape(Lang.Plugins.partition.Text.PartNum) ?></th>
<th><?cs var:html_escape(Lang.Plugins.partition.Text.Size) ?></th>
<th><?cs var:html_escape(Lang.Plugins.partition.Text.PartType) ?></th>
<th></th>
</tr>
<?cs /if ?>
<?cs loop: x = #0, subcount(Data.Plugins.partition.Parts)-1, #1 ?>
<tr>
@ -51,9 +56,7 @@
</div>
<?cs if:subcount(Data.Plugins.partition.Parts) > 0 ?>
<p class="note">
<?cs var:html_escape(Lang.Plugins.partition.Text.WarningMessage) ?>
</p>
<?cs call:hint(Lang.Plugins.partition.Text.WarningMessage) ?>
<?cs call:print_form_header("part_finish", "plugins/partition") ?>
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>

View File

@ -4,6 +4,8 @@
<h1><?cs var:html_escape(Lang.Plugins.partition.Title.Partition) ?></h1>
<?cs call:handle_messages() ?>
<p><?cs var:html_escape(Lang.Plugins.partition.Text.ProgressInfo) ?>
<ul>
<?cs loop: x = #0, subcount(Data.Plugins.partition.Parts)-1, #1 ?>

View File

@ -0,0 +1,10 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
url = self.URL + "plugins/partition?weblang=en"
self.register_auth(url)
self.cmd.go(url)
self.cmd.find('VERY careful')

View File

@ -3,7 +3,6 @@
<style type="text/css">
table.plugin_list {
text-align: center;
align:center;
}
table.plugin_list td, table.plugin_list th {
@ -15,12 +14,14 @@
<h1><?cs var:html_escape(Lang.Plugins.plugin_manager.Title.PluginManager) ?></h1>
<?cs call:handle_messages() ?>
<?cs call:print_form_header("manage_plugins", "plugins/plugin_manager") ?>
<h2><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.SystemPlugins) ?></h2>
<p>
<table class="plugin_list" align="center">
<table class="plugin_list">
<tr>
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.PluginName) ?></th>
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.PluginRank) ?></th>
@ -39,7 +40,7 @@
<h2><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.VolumePlugins) ?></h2>
<p>
<table class="plugin_list" align="center">
<table class="plugin_list">
<tr>
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.PluginName) ?></th>
<th><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.PluginRank) ?></th>

View File

@ -0,0 +1,12 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
url = self.URL + "plugins/plugin_manager?weblang=en"
self.register_auth(url)
self.cmd.go(url)
self.cmd.find('Plugin Manager')
self.cmd.find('System plugins')
self.cmd.find('Volume plugins')

View File

@ -2,6 +2,8 @@
<h1><?cs var:html_escape(Lang.Plugins.shutdown.Title.Shutdown) ?></h1>
<?cs call:handle_messages() ?>
<!--
<p style="text-align: center">
<?cs var:html_escape(Lang.Plugins.shutdown.Text.ShutdownInfo) ?>

View File

@ -6,6 +6,6 @@ class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
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"')
self.cmd.find('plugins/shutdown\?type=reboot')
self.cmd.find('plugins/shutdown\?type=shutdown')

View File

@ -2,6 +2,8 @@
<h1><?cs var:html_escape(Lang.Plugins.system_preferences.Title.Preferences) ?></h1>
<?cs call:handle_messages() ?>
<?cs # sort the Plugins - using the most stupid way :) ?>
<?cs loop: order = #0, #100, #1
?><?cs # plugins ?><?cs each:x = Settings.PluginList

View File

@ -0,0 +1,8 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_preferences_overview(self):
self.cmd.go(self.URL + "plugins/system_preferences?weblang=en")
self.cmd.find("Preferences")

View File

@ -6,7 +6,7 @@ from user_manager import RESERVED_USERS
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_users(self):
print self._getUsers()
cur_users = self._getUsers()
# self.cmd.showforms()

View File

@ -11,6 +11,8 @@
<h1><?cs var:html_escape(Lang.Plugins.user_manager.Title.UserManager) ?></h1>
<?cs call:handle_messages() ?>
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.AddUser) ?></h2>

View File

@ -0,0 +1,10 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
url = self.URL + "plugins/volume_details?weblang=en&device=%2Fdev%2Floop1"
self.register_auth(url)
self.cmd.go(url)
self.cmd.find('Technical details')

View File

@ -4,6 +4,8 @@
<h2><?cs var:html_escape(Lang.Plugins.volume_details.Title.Details) ?></h2>
<?cs call:handle_messages() ?>
<p><ul>
<li><?cs var:html_escape(Lang.Text.ContainerName) ?>: <?cs var:html_escape(Data.CurrentDisk.name) ?></li>
<li><?cs var:html_escape(Lang.Plugins.volume_details.Text.DeviceName) ?>: <?cs var:html_escape(Data.CurrentDisk.device) ?></li>

View File

@ -0,0 +1,10 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
url = self.URL + "plugins/volume_mount?weblang=en&device=%2Fdev%2Floop1"
self.register_auth(url)
self.cmd.go(url)
self.cmd.find('ctivate volume')

View File

@ -1,5 +1,7 @@
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Mount) ?></h2>
<?cs call:handle_messages() ?>
<p><?cs call:print_form_header("mount", "plugins/volume_mount") ?>
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
<?cs if:Data.CurrentDisk.encryption ?>

View File

@ -1,5 +1,7 @@
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Umount) ?></h2>
<?cs call:handle_messages() ?>
<?cs call:print_form_header("umount", "plugins/volume_mount") ?>
<p><input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
<input type="hidden" name="action" value="umount" />

View File

@ -0,0 +1,10 @@
import WebInterfaceTestClass
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
def test_read_form(self):
url = self.URL + "plugins/volume_props?weblang=en&device=%2Fdev%2Floop1"
self.register_auth(url)
self.cmd.go(url)
self.cmd.find('Properties')

View File

@ -4,11 +4,11 @@
<h2><?cs var:html_escape(Lang.Plugins.volume_props.Title.Properties) ?></h2>
<?cs call:handle_messages() ?>
<?cs if:Data.CurrentDisk.active ?>
<div class="unavailable_action">
<?cs var:html_escape(Lang.Plugins.volume_props.Text.UmountBeforeProps) ?>
</div>
<?cs call:hint(Lang.Plugins.volume_props.Text.UmountBeforeProps) ?>
<?cs else ?>
<table>