Rev 5805: Add tests for config save hook for remote configs. in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Jun 14 09:03:36 UTC 2011
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5805
revision-id: v.ladeuil+lp at free.fr-20110614090336-mqx0p4bbhpmtwohl
parent: v.ladeuil+lp at free.fr-20110614085912-cmfzaeojb9f6a1ni
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-hooks
timestamp: Tue 2011-06-14 11:03:36 +0200
message:
Add tests for config save hook for remote configs.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-06-14 08:59:12 +0000
+++ b/bzrlib/tests/test_config.py 2011-06-14 09:03:36 +0000
@@ -2088,7 +2088,6 @@
def assertLoadHook(self, expected_nb_calls, name, conf_class, *conf_args):
calls = []
def hook(*args):
- self.debug()
calls.append(args)
config.ConfigHooks.install_named_hook('old_load', hook, None)
self.addCleanup(
@@ -2116,6 +2115,30 @@
# SmartServerBranchGetConfigFile (in smart/branch.py)
self.assertLoadHook(2 ,'file', remote.RemoteBzrDirConfig, remote_bzrdir)
+ def assertSaveHook(self, conf):
+ calls = []
+ def hook(*args):
+ calls.append(args)
+ config.ConfigHooks.install_named_hook('old_save', hook, None)
+ self.addCleanup(
+ config.ConfigHooks.uninstall_named_hook, 'old_save', None)
+ self.assertLength(0, calls)
+ # Setting an option triggers a save
+ conf.set_option('foo', 'bar')
+ self.assertLength(1, calls)
+ # Since we can't assert about conf, we just use the number of calls ;-/
+
+ def test_save_hook_remote_branch(self):
+ remote_branch = branch.Branch.open(self.get_url('tree'))
+ self.addCleanup(remote_branch.lock_write().unlock)
+ self.assertSaveHook(remote_branch._get_config())
+
+ def test_save_hook_remote_bzrdir(self):
+ remote_branch = branch.Branch.open(self.get_url('tree'))
+ self.addCleanup(remote_branch.lock_write().unlock)
+ remote_bzrdir = bzrdir.BzrDir.open(self.get_url('tree'))
+ self.assertSaveHook(remote_bzrdir._get_config())
+
class TestOption(tests.TestCase):
More information about the bazaar-commits
mailing list