~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: Jelmer Vernooij
  • Date: 2012-04-02 01:44:26 UTC
  • mfrom: (6518 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6519.
  • Revision ID: jelmer@samba.org-20120402014426-0o5qtysohyl006b2
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    install_lazy_named_hook,
30
30
    known_hooks,
31
31
    known_hooks_key_to_object,
32
 
    known_hooks_key_to_parent_and_attribute,
33
32
    )
34
33
from bzrlib.symbol_versioning import (
35
34
    deprecated_in,
38
37
 
39
38
class TestHooks(tests.TestCase):
40
39
 
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'])
48
 
 
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'])
59
 
 
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')))
288
268
 
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')))
298
 
 
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(