/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: Vincent Ladeuil
  • Date: 2008-06-10 15:25:47 UTC
  • mto: This revision was merged to the branch mainline in revision 504.
  • Revision ID: v.ladeuil+lp@free.fr-20080610152547-dwmil1p8pd0mfpnl
Fix third failing test (thanks to jam).

* tests/test_commit.py:
(TestPendingRevisions.test_pending_revisions_multi_merge): Fix
provided by jam: bzr we now filter the pending merges so that only
the 'heads()' are included. We just ensure that the pending merges
contain the unique tips for the ancestries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Jelmer Venrooij <jelmer@samba.org>
 
1
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
from bzrlib.tests import TestCase
 
17
from bzrlib.tests import TestCase, TestCaseInTempDir
18
18
from bzrlib.plugins.gtk.olive import Preferences
19
19
 
 
20
import os
 
21
 
20
22
# FIXME: need to make sure that this also tests writing/reading.
21
 
class TestPreferences(TestCase):
 
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
 
22
28
    def test_create(self):
23
29
        Preferences()
24
30
 
25
31
    def test_add_bookmark(self):
26
32
        """make sure a bookmark can be added. This function is only supposed 
27
33
        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())
 
34
        self.assertTrue(self.prefs.add_bookmark("file://foobar"))
 
35
        self.assertTrue("file://foobar" in self.prefs.get_bookmarks())
31
36
 
32
37
    def test_add_bookmark_twice(self):
33
38
        """Adding an already present bookmark will result in False being 
34
39
        returned."""
35
 
        x = Preferences()
36
 
        self.assertTrue(x.add_bookmark("file://foobar"))
37
 
        self.assertFalse(x.add_bookmark("file://foobar"))
 
40
        self.assertTrue(self.prefs.add_bookmark("file://foobar"))
 
41
        self.assertFalse(self.prefs.add_bookmark("file://foobar"))
38
42
 
39
43
    def test_set_bookmark_title(self):
40
44
        """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")
 
45
        self.prefs.add_bookmark("file://foobar")
 
46
        self.prefs.set_bookmark_title("file://foobar", "My Bookmark")
44
47
 
45
48
    def test_remove_bookmark(self):
46
49
        """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())
 
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())
51
53
 
52
54
    def test_get_bookmarks_empty(self):
53
55
        """Test whether a new Preferences() object has an empty bookmarks 
54
56
        list."""
55
 
        x = Preferences()
56
 
        self.assertEqual([], x.get_bookmarks())
 
57
        self.assertEqual([], self.prefs.get_bookmarks())
57
58
 
58
59
    def test_get_bookmark_title_set(self):
59
60
        """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"))
 
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
64
 
65
65
    def test_get_bookmark_title_implicit(self):
66
66
        """Test getting a bookmark title for a bookmark that doesn't
67
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"))
 
68
        self.prefs.add_bookmark("file://bla")
 
69
        self.assertEqual("file://bla", self.prefs.get_bookmark_title("file://bla"))
71
70
 
72
71
    def test_set_preference(self):
73
72
        """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")
 
73
        self.prefs.set_preference("foo", True)
 
74
        self.prefs.set_preference("foo", False)
 
75
        self.prefs.set_preference("foo", "bloe")
78
76
 
79
77
    def test_get_preference_bool(self):
80
78
        """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"))
 
79
        self.prefs.set_preference("foo", True)
 
80
        self.assertEqual(True, self.prefs.get_preference("foo", "bool"))
84
81
 
85
82
    def test_get_preference_str(self):
86
83
        """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"))
 
84
        self.prefs.set_preference("bla", "bloe")
 
85
        self.assertEqual("bloe", self.prefs.get_preference("bla"))
90
86
 
91
87
    def test_get_preference_nonexistant(self):
92
88
        """Check whether get_preference returns None for nonexisting 
93
89
        options."""
94
 
        x = Preferences()
95
 
        self.assertEqual(None, x.get_preference("foo"))
 
90
        self.assertEqual(None, self.prefs.get_preference("foo"))
96
91