~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Robert Collins
  • Date: 2007-01-30 11:52:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2246.
  • Revision ID: robertc@robertcollins.net-20070130115230-2052dzn5xo9h6o07
Add install_hook to the BranchHooks class as the official means for installing a hook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
                           BzrDir, BzrDirFormat)
33
33
from bzrlib.errors import (NotBranchError,
34
34
                           UnknownFormatError,
 
35
                           UnknownHook,
35
36
                           UnsupportedFormatError,
36
37
                           )
37
38
 
175
176
        """The installed hooks object should be a BranchHooks."""
176
177
        # the installed hooks are saved in self._preserved_hooks.
177
178
        self.assertIsInstance(self._preserved_hooks, bzrlib.branch.BranchHooks)
 
179
 
 
180
    def test_install_hook_raises_unknown_hook(self):
 
181
        """install_hook should raise UnknownHook if a hook is unknown."""
 
182
        hooks = bzrlib.branch.BranchHooks()
 
183
        self.assertRaises(UnknownHook, hooks.install_hook, 'silly', None)
 
184
 
 
185
    def test_install_hook_appends_known_hook(self):
 
186
        """install_hook should append the callable for known hooks."""
 
187
        hooks = bzrlib.branch.BranchHooks()
 
188
        hooks.install_hook('set_rh', None)
 
189
        self.assertEqual(hooks['set_rh'], [None])