~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to tests/test_widgets.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-04-05 15:28:16 UTC
  • mfrom: (6.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20140405152816-6lijoax4cngiz5j5
Tags: 0.93-3
* debian/control:
  + Depend on python-gi (>= 3.10), older versions do not work
    with pitivi (Closes: #732813).
  + Add missing dependency on gir1.2-clutter-gst-2.0 (Closes: #743692).
  + Add suggests on gir1.2-notify-0.7 and gir1.2-gnomedesktop-3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Copyright (c) 2013, Alex Băluț <alexandru.balut@gmail.com>
 
4
#
 
5
# This program is free software; you can redistribute it and/or
 
6
# modify it under the terms of the GNU Lesser General Public
 
7
# License as published by the Free Software Foundation; either
 
8
# version 2.1 of the License, or (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
# Lesser General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU Lesser General Public
 
16
# License along with this program; if not, write to the
 
17
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 
18
# Boston, MA 02110-1301, USA.
 
19
 
 
20
from unittest import TestCase
 
21
 
 
22
from pitivi.utils.widgets import PathWidget, TextWidget, NumericWidget, ToggleWidget, ChoiceWidget, ColorWidget, FontWidget
 
23
 
 
24
 
 
25
class TestWidgets(TestCase):
 
26
 
 
27
    def testConstruction(self):
 
28
        widgets = (
 
29
            (PathWidget, "file:///home/", ()),
 
30
            (TextWidget, "banana", ()),
 
31
            (NumericWidget, 42, (100, 1)),
 
32
            (ToggleWidget, True, ()),
 
33
            (ChoiceWidget, "banana", ((
 
34
                ("banana", "banana"),
 
35
                ("apple", "apple"),
 
36
                ("pear", "pear")),)),
 
37
            (ColorWidget, 0x336699FF, (int,)),
 
38
            (FontWidget, "Sans 9", ()))
 
39
 
 
40
        for widget_class, default, args in widgets:
 
41
            widget = widget_class(*args, default=default)
 
42
            self.assertEqual(default, widget.getWidgetDefault())
 
43
            widget.setWidgetToDefault()
 
44
            self.assertEqual(default, widget.getWidgetValue())
 
45
            widget.setWidgetValue(default)
 
46
            self.assertEqual(default, widget.getWidgetValue())
 
47
 
 
48
    def testValidation(self):
 
49
        widget = TextWidget("^([a-zA-Z]+\s*)+$")
 
50
        bad_value = "1"
 
51
        self.assertNotEqual(bad_value, widget.getWidgetValue())
 
52
 
 
53
        widget = TextWidget("^\d+$", ("12", "14"))
 
54
        bad_value = "non-digits"
 
55
        self.assertNotEqual(bad_value, widget.getWidgetValue())