/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/test_preferences.py

  • Committer: rodney.dawes at canonical
  • Date: 2008-10-25 06:02:09 UTC
  • Revision ID: rodney.dawes@canonical.com-20081025060209-irlizouino63cs1m
        * preferences/__init__.py:
        Remove the dialog separator
        Remove useless extra call to self._create_pages()
        Make the default window size smaller
        Set the default border width on various widgets
        Set the current notebook page to the first one

        * preferences/identity.py:
        Set various border widths appropriately
        Align the labels to the left
        Remove the unneeded bold markup from the labels
        Change the "User Id" label to "E-Mail"
        Align the radio group labels to the top of the groups

        * preferences/plugins.py:
        Set various border widths appropriately
        Set the default paned position to something more sensible
        Set the shadow type on the treeview's scrolled window to in
        Align the Author and Version labels to the left

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
from bzrlib.tests import TestCase, TestCaseInTempDir
 
18
from bzrlib.plugins.gtk.olive import Preferences
 
19
 
 
20
import os
 
21
 
 
22
# FIXME: need to make sure that this also tests writing/reading.
 
23
class TestPreferences(TestCaseInTempDir):
 
24
    def setUp(self):
 
25
        super(TestPreferences, self).setUp()
 
26
        self.prefs = Preferences(os.path.join(self.test_dir, 'prefs'))
 
27
 
 
28
    def test_create(self):
 
29
        Preferences()
 
30
 
 
31
    def test_add_bookmark(self):
 
32
        """make sure a bookmark can be added. This function is only supposed 
 
33
        to store the location, not try to access it. """
 
34
        self.assertTrue(self.prefs.add_bookmark("file://foobar"))
 
35
        self.assertTrue("file://foobar" in self.prefs.get_bookmarks())
 
36
 
 
37
    def test_add_bookmark_twice(self):
 
38
        """Adding an already present bookmark will result in False being 
 
39
        returned."""
 
40
        self.assertTrue(self.prefs.add_bookmark("file://foobar"))
 
41
        self.assertFalse(self.prefs.add_bookmark("file://foobar"))
 
42
 
 
43
    def test_set_bookmark_title(self):
 
44
        """Test setting a title for an existing bookmark."""
 
45
        self.prefs.add_bookmark("file://foobar")
 
46
        self.prefs.set_bookmark_title("file://foobar", "My Bookmark")
 
47
 
 
48
    def test_remove_bookmark(self):
 
49
        """Test removing a bookmark."""
 
50
        self.prefs.add_bookmark("http://example.com/branch")
 
51
        self.prefs.remove_bookmark("http://example.com/branch")
 
52
        self.assertFalse("http://example.com/branch" in self.prefs.get_bookmarks())
 
53
 
 
54
    def test_get_bookmarks_empty(self):
 
55
        """Test whether a new Preferences() object has an empty bookmarks 
 
56
        list."""
 
57
        self.assertEqual([], self.prefs.get_bookmarks())
 
58
 
 
59
    def test_get_bookmark_title_set(self):
 
60
        """Test getting a title for an existing bookmark."""
 
61
        self.prefs.add_bookmark("file://foobar")
 
62
        self.prefs.set_bookmark_title("file://foobar", "My Bookmark")
 
63
        self.assertEqual("My Bookmark", self.prefs.get_bookmark_title("file://foobar"))
 
64
 
 
65
    def test_get_bookmark_title_implicit(self):
 
66
        """Test getting a bookmark title for a bookmark that doesn't
 
67
        have a title set."""
 
68
        self.prefs.add_bookmark("file://bla")
 
69
        self.assertEqual("file://bla", self.prefs.get_bookmark_title("file://bla"))
 
70
 
 
71
    def test_set_preference(self):
 
72
        """Check whether setting preferences works."""
 
73
        self.prefs.set_preference("foo", True)
 
74
        self.prefs.set_preference("foo", False)
 
75
        self.prefs.set_preference("foo", "bloe")
 
76
 
 
77
    def test_get_preference_bool(self):
 
78
        """Check whether a preference can be retrieved."""
 
79
        self.prefs.set_preference("foo", True)
 
80
        self.assertEqual(True, self.prefs.get_preference("foo", "bool"))
 
81
 
 
82
    def test_get_preference_str(self):
 
83
        """Check whether a string preference can be retrieved."""
 
84
        self.prefs.set_preference("bla", "bloe")
 
85
        self.assertEqual("bloe", self.prefs.get_preference("bla"))
 
86
 
 
87
    def test_get_preference_nonexistant(self):
 
88
        """Check whether get_preference returns None for nonexisting 
 
89
        options."""
 
90
        self.assertEqual(None, self.prefs.get_preference("foo"))
 
91