Rev 144: Actually add the preference tests this time (forgot to ran 'bzr add'...) in file:///home/jelmer/bzr-gtk/trunk/
Jelmer Vernooij
jelmer at samba.org
Sat Feb 3 10:45:46 GMT 2007
At file:///home/jelmer/bzr-gtk/trunk/
------------------------------------------------------------
revno: 144
revision-id: jelmer at samba.org-20070203104537-hbnjve7vmv1fm1pw
parent: jelmer at samba.org-20070203103836-7d0i7f40atktwgb8
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sat 2007-02-03 11:45:37 +0100
message:
Actually add the preference tests this time (forgot to ran 'bzr add'...)
Move more files to the top-level directory.
added:
tests/test_preferences.py test_preferences.py-20070203104345-ztgnupeolrh4sbey-1
renamed:
olive/errors.py => errors.py errors.py-20070129213417-8rr7unfjjdetfq83-1
olive/merge.py => merge.py merge.py-20061009195451-45vs0pe2nphnckxh-1
modified:
branch.py branch.py-20060718221951-cc4ts04p4d84mjth-1
checkout.py checkout.py-20060731181533-e0x1bgv7wum466kj-1
commit.py commit.py-20060721181724-0mfkrqwpsa09q1t3-3
push.py push.py-20060721181724-0mfkrqwpsa09q1t3-4
errors.py errors.py-20070129213417-8rr7unfjjdetfq83-1
merge.py merge.py-20061009195451-45vs0pe2nphnckxh-1
=== added file 'tests/test_preferences.py'
--- a/tests/test_preferences.py 1970-01-01 00:00:00 +0000
+++ b/tests/test_preferences.py 2007-02-03 10:45:37 +0000
@@ -0,0 +1,96 @@
+# Copyright (C) 2007 Jelmer Venrooij <jelmer at samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from bzrlib.tests import TestCase
+from bzrlib.plugins.gtk.olive import Preferences
+
+# FIXME: need to make sure that this also tests writing/reading.
+class TestPreferences(TestCase):
+ def test_create(self):
+ Preferences()
+
+ def test_add_bookmark(self):
+ """make sure a bookmark can be added. This function is only supposed
+ to store the location, not try to access it. """
+ x = Preferences()
+ self.assertTrue(x.add_bookmark("file://foobar"))
+ self.assertTrue("file://foobar" in x.get_bookmarks())
+
+ def test_add_bookmark_twice(self):
+ """Adding an already present bookmark will result in False being
+ returned."""
+ x = Preferences()
+ self.assertTrue(x.add_bookmark("file://foobar"))
+ self.assertFalse(x.add_bookmark("file://foobar"))
+
+ def test_set_bookmark_title(self):
+ """Test setting a title for an existing bookmark."""
+ x = Preferences()
+ x.add_bookmark("file://foobar")
+ x.set_bookmark_title("file://foobar", "My Bookmark")
+
+ def test_remove_bookmark(self):
+ """Test removing a bookmark."""
+ x = Preferences()
+ x.add_bookmark("http://example.com/branch")
+ x.remove_bookmark("http://example.com/branch")
+ self.assertFalse("http://example.com/branch" in x.get_bookmarks())
+
+ def test_get_bookmarks_empty(self):
+ """Test whether a new Preferences() object has an empty bookmarks
+ list."""
+ x = Preferences()
+ self.assertEqual([], x.get_bookmarks())
+
+ def test_get_bookmark_title_set(self):
+ """Test getting a title for an existing bookmark."""
+ x = Preferences()
+ x.add_bookmark("file://foobar")
+ x.set_bookmark_title("file://foobar", "My Bookmark")
+ self.assertEqual("My Bookmark", x.get_bookmark_title("file://foobar"))
+
+ def test_get_bookmark_title_implicit(self):
+ """Test getting a bookmark title for a bookmark that doesn't
+ have a title set."""
+ x = Preferences()
+ x.add_bookmark("file://bla")
+ self.assertEqual("file://bla", x.get_bookmark_title("file://bla"))
+
+ def test_set_preference(self):
+ """Check whether setting preferences works."""
+ x = Preferences()
+ x.set_preference("foo", True)
+ x.set_preference("foo", False)
+ x.set_preference("foo", "bloe")
+
+ def test_get_preference_bool(self):
+ """Check whether a preference can be retrieved."""
+ x = Preferences()
+ x.set_preference("foo", True)
+ self.assertEqual(True, x.get_preference("foo", "bool"))
+
+ def test_get_preference_str(self):
+ """Check whether a string preference can be retrieved."""
+ x = Preferences()
+ x.set_preference("bla", "bloe")
+ self.assertEqual("bloe", x.get_preference("bla"))
+
+ def test_get_preference_nonexistant(self):
+ """Check whether get_preference returns None for nonexisting
+ options."""
+ x = Preferences()
+ self.assertEqual(None, x.get_preference("foo"))
+
=== renamed file 'olive/errors.py' => 'errors.py'
--- a/olive/errors.py 2007-01-31 23:52:50 +0000
+++ b/errors.py 2007-02-03 10:45:37 +0000
@@ -16,7 +16,7 @@
import bzrlib.errors as errors
-from dialog import error_dialog
+from olive.dialog import error_dialog
def show_bzr_error(unbound):
"""Decorator that shows bazaar exceptions. """
=== renamed file 'olive/merge.py' => 'merge.py'
--- a/olive/merge.py 2007-01-29 23:27:09 +0000
+++ b/merge.py 2007-02-03 10:45:37 +0000
@@ -28,9 +28,9 @@
from bzrlib.branch import Branch
import bzrlib.errors as errors
-from dialog import error_dialog, info_dialog, warning_dialog
+from olive.dialog import error_dialog, info_dialog, warning_dialog
from errors import show_bzr_error
-from guifiles import GLADEFILENAME
+from olive.guifiles import GLADEFILENAME
class MergeDialog:
=== modified file 'branch.py'
--- a/branch.py 2007-02-03 10:25:09 +0000
+++ b/branch.py 2007-02-03 10:45:37 +0000
@@ -31,7 +31,7 @@
from bzrlib.config import GlobalConfig
import bzrlib.errors as errors
-from dialog import error_dialog, info_dialog
+from olive.dialog import error_dialog, info_dialog
class BranchDialog(gtk.Dialog):
=== modified file 'checkout.py'
--- a/checkout.py 2007-02-03 10:25:09 +0000
+++ b/checkout.py 2007-02-03 10:45:37 +0000
@@ -30,7 +30,7 @@
from bzrlib.branch import Branch
from bzrlib.config import GlobalConfig
-from dialog import error_dialog
+from olive.dialog import error_dialog
class CheckoutDialog(gtk.Dialog):
=== modified file 'commit.py'
--- a/commit.py 2007-02-03 10:25:09 +0000
+++ b/commit.py 2007-02-03 10:45:37 +0000
@@ -31,7 +31,6 @@
from dialog import error_dialog, question_dialog
from errors import show_bzr_error
-from guifiles import GLADEFILENAME
class CommitDialog(gtk.Dialog):
""" New implementation of the Commit dialog. """
=== modified file 'push.py'
--- a/push.py 2007-02-03 10:25:09 +0000
+++ b/push.py 2007-02-03 10:45:37 +0000
@@ -28,7 +28,7 @@
from bzrlib.config import LocationConfig
import bzrlib.errors as errors
-from dialog import error_dialog, info_dialog, question_dialog
+from olive.dialog import error_dialog, info_dialog, question_dialog
class PushDialog(gtk.Dialog):
More information about the bazaar-commits
mailing list