/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: Jelmer Vernooij
  • Date: 2012-07-09 15:23:26 UTC
  • mto: This revision was merged to the branch mainline in revision 794.
  • Revision ID: jelmer@samba.org-20120709152326-dzxb8zoz0btull7n
Remove bzr-notify.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Jelmer Venrooij <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
18
 
from bzrlib.plugins.gtk.olive import Preferences
19
 
 
20
 
# FIXME: need to make sure that this also tests writing/reading.
21
 
class TestPreferences(TestCase):
22
 
    def test_create(self):
23
 
        Preferences()
24
 
 
25
 
    def test_add_bookmark(self):
26
 
        """make sure a bookmark can be added. This function is only supposed 
27
 
        to store the location, not try to access it. """
28
 
        x = Preferences()
29
 
        self.assertTrue(x.add_bookmark("file://foobar"))
30
 
        self.assertTrue("file://foobar" in x.get_bookmarks())
31
 
 
32
 
    def test_add_bookmark_twice(self):
33
 
        """Adding an already present bookmark will result in False being 
34
 
        returned."""
35
 
        x = Preferences()
36
 
        self.assertTrue(x.add_bookmark("file://foobar"))
37
 
        self.assertFalse(x.add_bookmark("file://foobar"))
38
 
 
39
 
    def test_set_bookmark_title(self):
40
 
        """Test setting a title for an existing bookmark."""
41
 
        x = Preferences()
42
 
        x.add_bookmark("file://foobar")
43
 
        x.set_bookmark_title("file://foobar", "My Bookmark")
44
 
 
45
 
    def test_remove_bookmark(self):
46
 
        """Test removing a bookmark."""
47
 
        x = Preferences()
48
 
        x.add_bookmark("http://example.com/branch")
49
 
        x.remove_bookmark("http://example.com/branch")
50
 
        self.assertFalse("http://example.com/branch" in x.get_bookmarks())
51
 
 
52
 
    def test_get_bookmarks_empty(self):
53
 
        """Test whether a new Preferences() object has an empty bookmarks 
54
 
        list."""
55
 
        x = Preferences()
56
 
        self.assertEqual([], x.get_bookmarks())
57
 
 
58
 
    def test_get_bookmark_title_set(self):
59
 
        """Test getting a title for an existing bookmark."""
60
 
        x = Preferences()
61
 
        x.add_bookmark("file://foobar")
62
 
        x.set_bookmark_title("file://foobar", "My Bookmark")
63
 
        self.assertEqual("My Bookmark", x.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
 
        x = Preferences()
69
 
        x.add_bookmark("file://bla")
70
 
        self.assertEqual("file://bla", x.get_bookmark_title("file://bla"))
71
 
 
72
 
    def test_set_preference(self):
73
 
        """Check whether setting preferences works."""
74
 
        x = Preferences()
75
 
        x.set_preference("foo", True)
76
 
        x.set_preference("foo", False)
77
 
        x.set_preference("foo", "bloe")
78
 
 
79
 
    def test_get_preference_bool(self):
80
 
        """Check whether a preference can be retrieved."""
81
 
        x = Preferences()
82
 
        x.set_preference("foo", True)
83
 
        self.assertEqual(True, x.get_preference("foo", "bool"))
84
 
 
85
 
    def test_get_preference_str(self):
86
 
        """Check whether a string preference can be retrieved."""
87
 
        x = Preferences()
88
 
        x.set_preference("bla", "bloe")
89
 
        self.assertEqual("bloe", x.get_preference("bla"))
90
 
 
91
 
    def test_get_preference_nonexistant(self):
92
 
        """Check whether get_preference returns None for nonexisting 
93
 
        options."""
94
 
        x = Preferences()
95
 
        self.assertEqual(None, x.get_preference("foo"))
96