39
38
class TestHooks(tests.TestCase):
41
def test_create_hook_first(self):
42
hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks")
43
doc = ("Invoked after changing the tip of a branch object. Called with"
44
"a bzrlib.branch.PostChangeBranchTipParams object")
45
hook = HookPoint("post_tip_change", doc, (0, 15), None)
46
self.applyDeprecated(deprecated_in((2, 4)), hooks.create_hook, hook)
47
self.assertEqual(hook, hooks['post_tip_change'])
49
def test_create_hook_name_collision_errors(self):
50
hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks")
51
doc = ("Invoked after changing the tip of a branch object. Called with"
52
"a bzrlib.branch.PostChangeBranchTipParams object")
53
hook = HookPoint("post_tip_change", doc, (0, 15), None)
54
hook2 = HookPoint("post_tip_change", None, None, None)
55
self.applyDeprecated(deprecated_in((2, 4)), hooks.create_hook, hook)
56
self.assertRaises(errors.DuplicateKey, self.applyDeprecated,
57
deprecated_in((2, 4, 0)), hooks.create_hook, hook2)
58
self.assertEqual(hook, hooks['post_tip_change'])
60
40
def test_docs(self):
61
41
"""docs() should return something reasonable about the Hooks."""
62
42
class MyHooks(Hooks):
286
266
self.assertIs(branch.Branch.hooks,
287
267
known_hooks_key_to_object(('bzrlib.branch', 'Branch.hooks')))
289
def test_known_hooks_key_to_parent_and_attribute_deprecated(self):
290
self.assertEqual((branch.Branch, 'hooks'),
291
self.applyDeprecated(deprecated_in((2,3)),
292
known_hooks_key_to_parent_and_attribute,
293
('bzrlib.branch', 'Branch.hooks')))
294
self.assertEqual((branch, 'Branch'),
295
self.applyDeprecated(deprecated_in((2,3)),
296
known_hooks_key_to_parent_and_attribute,
297
('bzrlib.branch', 'Branch')))
299
269
def test_known_hooks_key_to_parent_and_attribute(self):
300
270
self.assertEqual((branch.Branch, 'hooks'),
301
271
known_hooks.key_to_parent_and_attribute(