[pitivi] tests: Move PreferencesDialog tests to test_prefs.py
- From: Mathieu Duponchelle <mathieudu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] tests: Move PreferencesDialog tests to test_prefs.py
- Date: Tue, 4 Feb 2014 21:53:28 +0000 (UTC)
commit 70c74bc29309160928fb13b3361a7fe7b196f208
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Jan 10 22:12:06 2014 +0100
tests: Move PreferencesDialog tests to test_prefs.py
pitivi/dialogs/prefs.py | 84 --------------------------------------------
tests/Makefile.am | 1 +
tests/test_prefs.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 90 insertions(+), 84 deletions(-)
---
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index ae2e30c..44d74a1 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -396,87 +396,3 @@ class PreferencesDialog(object):
if not self.settings.isDefault(attrname):
return True
return False
-
-## Preference Test Cases
-
-if __name__ == "__main__":
-
- OPTIONS = (
- ('numericPreference1', 10),
- ('numericPreference2', 2.4),
- ('textPreference1', "banana"),
- ('textPreference2', "42"),
- ('aPathPreference', "file:///etc/"),
- ('aChoicePreference', 42),
- ('aLongChoicePreference', "Mauve"),
- ('aTogglePreference', True),
- ('aFontPreference', "Sans 9"),
- )
-
- for attrname, default in OPTIONS:
- GlobalSettings.addConfigOption(attrname, default=default)
-
-## Numeric
-
- PreferencesDialog.addNumericPreference('numericPreference1',
- label="Open Range",
- section="Test",
- description="This option has no upper bound",
- lower=-10)
-
- PreferencesDialog.addNumericPreference('numericPreference2',
- label="Closed Range",
- section="Test",
- description="This option has both upper and lower bounds",
- lower=-10,
- upper=10000)
-
-## Text
-
- PreferencesDialog.addTextPreference('textPreference1',
- label="Unfiltered",
- section="Test",
- description="Anything can go in this box")
-
- PreferencesDialog.addTextPreference('textPreference2',
- label="Numbers only",
- section="Test",
- description="This input validates its input with a regex",
- matches=r"^-?\d+(\.\d+)?$")
-
-## other
- PreferencesDialog.addPathPreference('aPathPreference',
- label="Test Path",
- section="Test",
- description="Test the path widget")
-
- PreferencesDialog.addChoicePreference('aChoicePreference',
- label="Swallow Velocity",
- section="Test",
- description="What is the airspeed velocity of a coconut-laden swallow?",
- choices=(
- ("42 Knots", 32),
- ("9 furlongs per fortnight", 42),
- ("I don't know that!", None)))
-
- PreferencesDialog.addChoicePreference('aLongChoicePreference',
- label="Favorite Color",
- section="Test",
- description="What is the color of the parrot's plumage?",
- choices=(
- ("Mauve", "Mauve"),
- ("Chartreuse", "Chartreuse"),
- ("Magenta", "Magenta"),
- ("Pink", "Pink"),
- ("Norwegian Blue", "Norwegian Blue"),
- ("Yellow Ochre", "Yellow Ochre")))
-
- PreferencesDialog.addTogglePreference('aTogglePreference',
- label="Test Toggle",
- section="Test",
- description="Test the toggle widget")
-
- PreferencesDialog.addFontPreference('aFontPreference',
- label="Foo Font",
- section="Test",
- description="Test the font widget")
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 37bae1a..43fc94a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,6 +6,7 @@ tests = test_basic.py \
test_common.py \
test_log.py \
test_misc.py \
+ test_prefs.py \
test_preset.py \
test_project.py \
test_projectmanager.py \
diff --git a/tests/test_prefs.py b/tests/test_prefs.py
new file mode 100644
index 0000000..dd77661
--- /dev/null
+++ b/tests/test_prefs.py
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2009, Brandon Lewis <brandon_lewis berkeley edu>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+import unittest
+
+from pitivi.dialogs.prefs import PreferencesDialog
+
+
+class PreferencesDialogTest(unittest.TestCase):
+
+ def testNumeric(self):
+ PreferencesDialog.addNumericPreference('numericPreference1',
+ label="Open Range",
+ section="Test",
+ description="This option has no upper bound",
+ lower=-10)
+ self.assertTrue('numericPreference1' in PreferencesDialog.prefs['Test'])
+
+ PreferencesDialog.addNumericPreference('numericPreference2',
+ label="Closed Range",
+ section="Test",
+ description="This option has both upper and lower bounds",
+ lower=-10,
+ upper=10000)
+
+ def testText(self):
+ PreferencesDialog.addTextPreference('textPreference1',
+ label="Unfiltered",
+ section="Test",
+ description="Anything can go in this box")
+
+ PreferencesDialog.addTextPreference('textPreference2',
+ label="Numbers only",
+ section="Test",
+ description="This input validates its input with a regex",
+ matches=r"^-?\d+(\.\d+)?$")
+
+ def testOther(self):
+ PreferencesDialog.addPathPreference('aPathPreference',
+ label="Test Path",
+ section="Test",
+ description="Test the path widget")
+
+ PreferencesDialog.addChoicePreference('aChoicePreference',
+ label="Swallow Velocity",
+ section="Test",
+ description="What is the airspeed velocity of a coconut-laden swallow?",
+ choices=(
+ ("42 Knots", 32),
+ ("9 furlongs per fortnight", 42),
+ ("I don't know that!", None)))
+
+ PreferencesDialog.addChoicePreference('aLongChoicePreference',
+ label="Favorite Color",
+ section="Test",
+ description="What is the color of the parrot's plumage?",
+ choices=(
+ ("Mauve", "Mauve"),
+ ("Chartreuse", "Chartreuse"),
+ ("Magenta", "Magenta"),
+ ("Pink", "Pink"),
+ ("Norwegian Blue", "Norwegian Blue"),
+ ("Yellow Ochre", "Yellow Ochre")))
+
+ PreferencesDialog.addTogglePreference('aTogglePreference',
+ label="Test Toggle",
+ section="Test",
+ description="Test the toggle widget")
+
+ PreferencesDialog.addFontPreference('aFontPreference',
+ label="Foo Font",
+ section="Test",
+ description="Test the font widget")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]