1
# Copyright (C) 2007 Jelmer Venrooij <jelmer@samba.org>
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.
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.
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
17
from bzrlib.tests import TestCase
18
from bzrlib.plugins.gtk.olive import Preferences
20
# FIXME: need to make sure that this also tests writing/reading.
21
class TestPreferences(TestCase):
22
def test_create(self):
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. """
29
self.assertTrue(x.add_bookmark("file://foobar"))
30
self.assertTrue("file://foobar" in x.get_bookmarks())
32
def test_add_bookmark_twice(self):
33
"""Adding an already present bookmark will result in False being
36
self.assertTrue(x.add_bookmark("file://foobar"))
37
self.assertFalse(x.add_bookmark("file://foobar"))
39
def test_set_bookmark_title(self):
40
"""Test setting a title for an existing bookmark."""
42
x.add_bookmark("file://foobar")
43
x.set_bookmark_title("file://foobar", "My Bookmark")
45
def test_remove_bookmark(self):
46
"""Test removing a bookmark."""
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())
52
def test_get_bookmarks_empty(self):
53
"""Test whether a new Preferences() object has an empty bookmarks
56
self.assertEqual([], x.get_bookmarks())
58
def test_get_bookmark_title_set(self):
59
"""Test getting a title for an existing bookmark."""
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"))
65
def test_get_bookmark_title_implicit(self):
66
"""Test getting a bookmark title for a bookmark that doesn't
69
x.add_bookmark("file://bla")
70
self.assertEqual("file://bla", x.get_bookmark_title("file://bla"))
72
def test_set_preference(self):
73
"""Check whether setting preferences works."""
75
x.set_preference("foo", True)
76
x.set_preference("foo", False)
77
x.set_preference("foo", "bloe")
79
def test_get_preference_bool(self):
80
"""Check whether a preference can be retrieved."""
82
x.set_preference("foo", True)
83
self.assertEqual(True, x.get_preference("foo", "bool"))
85
def test_get_preference_str(self):
86
"""Check whether a string preference can be retrieved."""
88
x.set_preference("bla", "bloe")
89
self.assertEqual("bloe", x.get_preference("bla"))
91
def test_get_preference_nonexistant(self):
92
"""Check whether get_preference returns None for nonexisting
95
self.assertEqual(None, x.get_preference("foo"))