~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: Martin
  • Date: 2009-11-07 08:02:13 UTC
  • mfrom: (4789 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4809.
  • Revision ID: gzlist@googlemail.com-20091107080213-jad185091b3l69ih
Merge bzr.dev 4789 to resolve conflict from the disabling of plink auto-detection, and relocate NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the core Hooks logic."""
18
18
 
19
 
from bzrlib import branch, errors
 
19
from bzrlib import (
 
20
    branch,
 
21
    errors,
 
22
    tests,
 
23
    )
20
24
from bzrlib.hooks import (
21
25
    HookPoint,
22
26
    Hooks,
24
28
    known_hooks_key_to_object,
25
29
    known_hooks_key_to_parent_and_attribute,
26
30
    )
27
 
from bzrlib.errors import (
28
 
    UnknownHook,
29
 
    )
30
 
 
31
 
from bzrlib.tests import TestCase
32
 
 
33
 
 
34
 
class TestHooks(TestCase):
 
31
 
 
32
 
 
33
class TestHooks(tests.TestCase):
35
34
 
36
35
    def test_create_hook_first(self):
37
36
        hooks = Hooks()
80
79
            "~~~~~~~~~~~~~~~\n"
81
80
            "\n"
82
81
            "Introduced in: 1.4\n"
83
 
            "Deprecated in: Not deprecated\n"
84
82
            "\n"
85
83
            "Invoked after the tip of a branch changes. Called with a\n"
86
84
            "ChangeBranchTipParams object.\n"
89
87
            "~~~~~~~~~~~~~~\n"
90
88
            "\n"
91
89
            "Introduced in: 1.6\n"
92
 
            "Deprecated in: Not deprecated\n"
93
90
            "\n"
94
91
            "Invoked before the tip of a branch changes. Called with a\n"
95
92
            "ChangeBranchTipParams object. Hooks should raise TipChangeRejected to\n"
97
94
 
98
95
    def test_install_named_hook_raises_unknown_hook(self):
99
96
        hooks = Hooks()
100
 
        self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
 
97
        self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly',
101
98
                          None, "")
102
99
 
103
100
    def test_install_named_hook_appends_known_hook(self):
113
110
        self.assertEqual("demo", hooks.get_hook_name(None))
114
111
 
115
112
 
116
 
class TestHook(TestCase):
 
113
class TestHook(tests.TestCase):
117
114
 
118
115
    def test___init__(self):
119
116
        doc = ("Invoked after changing the tip of a branch object. Called with"
133
130
            "~~~~~~~~~~~~~~~\n"
134
131
            "\n"
135
132
            "Introduced in: 0.15\n"
136
 
            "Deprecated in: Not deprecated\n"
137
133
            "\n"
138
134
            "Invoked after changing the tip of a branch object. Called with a\n"
139
135
            "bzrlib.branch.PostChangeBranchTipParams object\n", hook.docs())
157
153
            callback_repr, repr(hook))
158
154
 
159
155
 
160
 
class TestHookRegistry(TestCase):
 
156
class TestHookRegistry(tests.TestCase):
161
157
 
162
158
    def test_items_are_reasonable_keys(self):
163
159
        # All the items in the known_hooks registry need to map from
173
169
            new_hooks = factory()
174
170
            self.assertIsInstance(obj, Hooks)
175
171
            self.assertEqual(type(obj), type(new_hooks))
 
172
            self.assertEqual("No hook name", new_hooks.get_hook_name(None))
176
173
 
177
174
    def test_known_hooks_key_to_object(self):
178
175
        self.assertIs(branch.Branch.hooks,