bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
| 
169
by Jelmer Vernooij
 Fix typo.  | 
1  | 
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
 | 
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
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  | 
||
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
17  | 
from bzrlib.tests import TestCase, TestCaseInTempDir  | 
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
18  | 
from bzrlib.plugins.gtk.olive import Preferences  | 
19  | 
||
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
20  | 
import os  | 
21  | 
||
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
22  | 
# FIXME: need to make sure that this also tests writing/reading.
 | 
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
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  | 
||
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
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. """
 | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
34  | 
self.assertTrue(self.prefs.add_bookmark("file://foobar"))  | 
35  | 
self.assertTrue("file://foobar" in self.prefs.get_bookmarks())  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
36  | 
|
37  | 
def test_add_bookmark_twice(self):  | 
|
38  | 
"""Adding an already present bookmark will result in False being  | 
|
39  | 
        returned."""
 | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
40  | 
self.assertTrue(self.prefs.add_bookmark("file://foobar"))  | 
41  | 
self.assertFalse(self.prefs.add_bookmark("file://foobar"))  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
42  | 
|
43  | 
def test_set_bookmark_title(self):  | 
|
44  | 
"""Test setting a title for an existing bookmark."""  | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
45  | 
self.prefs.add_bookmark("file://foobar")  | 
46  | 
self.prefs.set_bookmark_title("file://foobar", "My Bookmark")  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
47  | 
|
48  | 
def test_remove_bookmark(self):  | 
|
49  | 
"""Test removing a bookmark."""  | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
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())  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
53  | 
|
54  | 
def test_get_bookmarks_empty(self):  | 
|
55  | 
"""Test whether a new Preferences() object has an empty bookmarks  | 
|
56  | 
        list."""
 | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
57  | 
self.assertEqual([], self.prefs.get_bookmarks())  | 
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
58  | 
|
59  | 
def test_get_bookmark_title_set(self):  | 
|
60  | 
"""Test getting a title for an existing bookmark."""  | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
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"))  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
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."""
 | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
68  | 
self.prefs.add_bookmark("file://bla")  | 
69  | 
self.assertEqual("file://bla", self.prefs.get_bookmark_title("file://bla"))  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
70  | 
|
71  | 
def test_set_preference(self):  | 
|
72  | 
"""Check whether setting preferences works."""  | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
73  | 
self.prefs.set_preference("foo", True)  | 
74  | 
self.prefs.set_preference("foo", False)  | 
|
75  | 
self.prefs.set_preference("foo", "bloe")  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
76  | 
|
77  | 
def test_get_preference_bool(self):  | 
|
78  | 
"""Check whether a preference can be retrieved."""  | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
79  | 
self.prefs.set_preference("foo", True)  | 
80  | 
self.assertEqual(True, self.prefs.get_preference("foo", "bool"))  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
81  | 
|
82  | 
def test_get_preference_str(self):  | 
|
83  | 
"""Check whether a string preference can be retrieved."""  | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
84  | 
self.prefs.set_preference("bla", "bloe")  | 
85  | 
self.assertEqual("bloe", self.prefs.get_preference("bla"))  | 
|
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
86  | 
|
87  | 
def test_get_preference_nonexistant(self):  | 
|
88  | 
"""Check whether get_preference returns None for nonexisting  | 
|
89  | 
        options."""
 | 
|
| 
170
by Jelmer Vernooij
 Add test argument to Preferences().  | 
90  | 
self.assertEqual(None, self.prefs.get_preference("foo"))  | 
| 
144
by Jelmer Vernooij
 Actually add the preference tests this time (forgot to ran 'bzr add'...)  | 
91  |