From c35e204a7b13aaeaafca40c24f04fbd0cdba3a3d Mon Sep 17 00:00:00 2001 From: lars Date: Thu, 2 Nov 2006 14:01:09 +0000 Subject: [PATCH] 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 --- pythonrewrite/plugins/date/form_date.cs | 2 ++ pythonrewrite/plugins/disks/disks.cs | 4 ++- pythonrewrite/plugins/disks/lang/de.hdf | 6 ++++ pythonrewrite/plugins/disks/lang/en.hdf | 1 + pythonrewrite/plugins/disks/unittests.py | 9 ++++++ pythonrewrite/plugins/format_fs/unittests.py | 10 +++++++ .../plugins/format_fs/volume_format.cs | 17 ++++++----- .../plugins/format_fs/volume_format_luks.cs | 8 ++--- pythonrewrite/plugins/help/doc.cs | 2 ++ pythonrewrite/plugins/help/unittests.py | 29 +++++++++++++++++++ pythonrewrite/plugins/logs/show_log.cs | 2 ++ pythonrewrite/plugins/network/form_network.cs | 4 +++ pythonrewrite/plugins/network/network.py | 3 +- pythonrewrite/plugins/network/unittests.py | 2 +- pythonrewrite/plugins/partition/partition.py | 26 ++++++----------- .../plugins/partition/select_device.cs | 11 +++---- .../plugins/partition/set_partitions.cs | 21 ++++++++------ .../plugins/partition/show_format_progress.cs | 2 ++ pythonrewrite/plugins/partition/unittests.py | 10 +++++++ .../plugins/plugin_manager/plugin_list.cs | 9 +++--- .../plugins/plugin_manager/unittests.py | 12 ++++++++ .../plugins/shutdown/form_shutdown.cs | 2 ++ pythonrewrite/plugins/shutdown/unittests.py | 4 +-- .../system_preferences/show_plugins.cs | 2 ++ .../plugins/system_preferences/unittests.py | 8 +++++ .../plugins/user_manager/unittests.py | 4 +-- .../plugins/user_manager/user_list.cs | 2 ++ .../plugins/volume_details/unittests.py | 10 +++++++ .../plugins/volume_details/volume_details.cs | 2 ++ .../plugins/volume_mount/unittests.py | 10 +++++++ .../plugins/volume_mount/volume_mount.cs | 2 ++ .../plugins/volume_mount/volume_umount.cs | 2 ++ .../plugins/volume_props/unittests.py | 10 +++++++ .../plugins/volume_props/volume_properties.cs | 6 ++-- 34 files changed, 197 insertions(+), 57 deletions(-) create mode 100644 pythonrewrite/plugins/disks/lang/de.hdf create mode 100644 pythonrewrite/plugins/disks/unittests.py create mode 100644 pythonrewrite/plugins/format_fs/unittests.py create mode 100644 pythonrewrite/plugins/help/unittests.py create mode 100644 pythonrewrite/plugins/partition/unittests.py create mode 100644 pythonrewrite/plugins/plugin_manager/unittests.py create mode 100644 pythonrewrite/plugins/system_preferences/unittests.py create mode 100644 pythonrewrite/plugins/volume_details/unittests.py create mode 100644 pythonrewrite/plugins/volume_mount/unittests.py create mode 100644 pythonrewrite/plugins/volume_props/unittests.py diff --git a/pythonrewrite/plugins/date/form_date.cs b/pythonrewrite/plugins/date/form_date.cs index 97fdb10..3f58f4b 100644 --- a/pythonrewrite/plugins/date/form_date.cs +++ b/pythonrewrite/plugins/date/form_date.cs @@ -2,6 +2,8 @@

+ +


diff --git a/pythonrewrite/plugins/disks/disks.cs b/pythonrewrite/plugins/disks/disks.cs index 01c7478..f18f682 100644 --- a/pythonrewrite/plugins/disks/disks.cs +++ b/pythonrewrite/plugins/disks/disks.cs @@ -2,10 +2,12 @@

+ + - NO DISKS + diff --git a/pythonrewrite/plugins/disks/lang/de.hdf b/pythonrewrite/plugins/disks/lang/de.hdf new file mode 100644 index 0000000..c2ef355 --- /dev/null +++ b/pythonrewrite/plugins/disks/lang/de.hdf @@ -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! diff --git a/pythonrewrite/plugins/disks/lang/en.hdf b/pythonrewrite/plugins/disks/lang/en.hdf index 098ae23..f30795a 100644 --- a/pythonrewrite/plugins/disks/lang/en.hdf +++ b/pythonrewrite/plugins/disks/lang/en.hdf @@ -3,3 +3,4 @@ Link = Disks Title.Disks = Available disks +Text.NoDisksAvailable = No available disks were found! diff --git a/pythonrewrite/plugins/disks/unittests.py b/pythonrewrite/plugins/disks/unittests.py new file mode 100644 index 0000000..778e07f --- /dev/null +++ b/pythonrewrite/plugins/disks/unittests.py @@ -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") + diff --git a/pythonrewrite/plugins/format_fs/unittests.py b/pythonrewrite/plugins/format_fs/unittests.py new file mode 100644 index 0000000..8e3f533 --- /dev/null +++ b/pythonrewrite/plugins/format_fs/unittests.py @@ -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') + diff --git a/pythonrewrite/plugins/format_fs/volume_format.cs b/pythonrewrite/plugins/format_fs/volume_format.cs index 82a20ad..09f86ca 100644 --- a/pythonrewrite/plugins/format_fs/volume_format.cs +++ b/pythonrewrite/plugins/format_fs/volume_format.cs @@ -4,28 +4,29 @@

+ + -
- -
+ + +

-

-

+

diff --git a/pythonrewrite/plugins/format_fs/volume_format_luks.cs b/pythonrewrite/plugins/format_fs/volume_format_luks.cs index 69fd554..940ac22 100644 --- a/pythonrewrite/plugins/format_fs/volume_format_luks.cs +++ b/pythonrewrite/plugins/format_fs/volume_format_luks.cs @@ -4,15 +4,15 @@

+ + -
- -
+ -

+

:

: + + diff --git a/pythonrewrite/plugins/help/unittests.py b/pythonrewrite/plugins/help/unittests.py new file mode 100644 index 0000000..914e30b --- /dev/null +++ b/pythonrewrite/plugins/help/unittests.py @@ -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") + diff --git a/pythonrewrite/plugins/logs/show_log.cs b/pythonrewrite/plugins/logs/show_log.cs index cff0446..623b4b7 100644 --- a/pythonrewrite/plugins/logs/show_log.cs +++ b/pythonrewrite/plugins/logs/show_log.cs @@ -8,6 +8,8 @@

+ +

diff --git a/pythonrewrite/plugins/network/form_network.cs b/pythonrewrite/plugins/network/form_network.cs index 7373404..e2b6786 100644 --- a/pythonrewrite/plugins/network/form_network.cs +++ b/pythonrewrite/plugins/network/form_network.cs @@ -6,6 +6,8 @@

+ +

@@ -24,3 +26,5 @@ + + diff --git a/pythonrewrite/plugins/network/network.py b/pythonrewrite/plugins/network/network.py index 9672ef4..eddf232 100644 --- a/pythonrewrite/plugins/network/network.py +++ b/pythonrewrite/plugins/network/network.py @@ -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" diff --git a/pythonrewrite/plugins/network/unittests.py b/pythonrewrite/plugins/network/unittests.py index 8224b16..092a27d 100644 --- a/pythonrewrite/plugins/network/unittests.py +++ b/pythonrewrite/plugins/network/unittests.py @@ -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 diff --git a/pythonrewrite/plugins/partition/partition.py b/pythonrewrite/plugins/partition/partition.py index a28887b..f751967 100644 --- a/pythonrewrite/plugins/partition/partition.py +++ b/pythonrewrite/plugins/partition/partition.py @@ -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 - if self.withConfigPartition: - deviceSize -= self.ConfigPartition["size"] - return deviceSize - except ValueError: - pass - return 0 + import CryptoBoxTools + deviceSize = CryptoBoxTools.getBlockDeviceSize(device) + if deviceSize < 0: return 0 + if self.withConfigPartition: + deviceSize -= self.ConfigPartition["size"] + return deviceSize def __isWithConfigPartition(self, args): diff --git a/pythonrewrite/plugins/partition/select_device.cs b/pythonrewrite/plugins/partition/select_device.cs index 93803cf..5215be1 100644 --- a/pythonrewrite/plugins/partition/select_device.cs +++ b/pythonrewrite/plugins/partition/select_device.cs @@ -4,14 +4,19 @@

+ + 0 ?> + +


@@ -22,10 +27,6 @@ --> -

- -

-
diff --git a/pythonrewrite/plugins/partition/set_partitions.cs b/pythonrewrite/plugins/partition/set_partitions.cs index be2c3ae..81d18d6 100644 --- a/pythonrewrite/plugins/partition/set_partitions.cs +++ b/pythonrewrite/plugins/partition/set_partitions.cs @@ -4,14 +4,19 @@

+ +
- - - - - - + 0 ?> + + + + + + + + @@ -51,9 +56,7 @@ 0 ?> -

- -

+ diff --git a/pythonrewrite/plugins/partition/show_format_progress.cs b/pythonrewrite/plugins/partition/show_format_progress.cs index d5530ab..126d37b 100644 --- a/pythonrewrite/plugins/partition/show_format_progress.cs +++ b/pythonrewrite/plugins/partition/show_format_progress.cs @@ -4,6 +4,8 @@

+ +