~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Aaron Bentley
  • Date: 2007-02-06 14:52:16 UTC
  • mfrom: (2266 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2268.
  • Revision ID: abentley@panoramicfeedback.com-20070206145216-fcpi8o3ufvuzwbp9
Merge bzr.dev

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
 
162
163
        self.assertEqual(made_branch.base, target_branch.base)
163
164
        opened_branch = branch_dir.open_branch()
164
165
        self.assertEqual(opened_branch.base, target_branch.base)
 
166
 
 
167
 
 
168
class TestHooks(TestCase):
 
169
 
 
170
    def test_constructor(self):
 
171
        """Check that creating a BranchHooks instance has the right defaults."""
 
172
        hooks = bzrlib.branch.BranchHooks()
 
173
        self.assertTrue("set_rh" in hooks, "set_rh not in %s" % hooks)
 
174
 
 
175
    def test_installed_hooks_are_BranchHooks(self):
 
176
        """The installed hooks object should be a BranchHooks."""
 
177
        # the installed hooks are saved in self._preserved_hooks.
 
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])