~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: Robert Collins
  • Date: 2009-03-27 04:10:25 UTC
  • mfrom: (4208 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4216.
  • Revision ID: robertc@robertcollins.net-20090327041025-rgutx4q03xo4pq6l
Resolve NEWS conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for the core Hooks logic."""
18
18
 
28
28
    UnknownHook,
29
29
    )
30
30
 
31
 
from bzrlib.symbol_versioning import one_five
32
31
from bzrlib.tests import TestCase
33
32
 
34
33
 
96
95
            "ChangeBranchTipParams object. Hooks should raise TipChangeRejected to\n"
97
96
            "signal that a tip change is not permitted.\n", hooks.docs())
98
97
 
99
 
    def test_install_hook_raises_unknown_hook(self):
100
 
        """install_hook should raise UnknownHook if a hook is unknown."""
101
 
        hooks = Hooks()
102
 
        self.assertRaises(UnknownHook, self.applyDeprecated, one_five,
103
 
                          hooks.install_hook, 'silly', None)
104
 
 
105
 
    def test_install_hook_appends_known_hook(self):
106
 
        """install_hook should append the callable for known hooks."""
107
 
        hooks = Hooks()
108
 
        hooks['set_rh'] = []
109
 
        self.applyDeprecated(one_five, hooks.install_hook, 'set_rh', None)
110
 
        self.assertEqual(hooks['set_rh'], [None])
111
 
 
112
98
    def test_install_named_hook_raises_unknown_hook(self):
113
99
        hooks = Hooks()
114
100
        self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
126
112
        hooks.install_named_hook('set_rh', None, "demo")
127
113
        self.assertEqual("demo", hooks.get_hook_name(None))
128
114
 
129
 
    def test_name_hook_and_retrieve_name(self):
130
 
        """name_hook puts the name in the names mapping."""
131
 
        hooks = Hooks()
132
 
        hooks['set_rh'] = []
133
 
        self.applyDeprecated(one_five, hooks.install_hook, 'set_rh', None)
134
 
        hooks.name_hook(None, 'demo')
135
 
        self.assertEqual("demo", hooks.get_hook_name(None))
136
 
 
137
 
    def test_get_unnamed_hook_name_is_unnamed(self):
138
 
        hooks = Hooks()
139
 
        hooks['set_rh'] = []
140
 
        self.applyDeprecated(one_five, hooks.install_hook, 'set_rh', None)
141
 
        self.assertEqual("No hook name", hooks.get_hook_name(None))
142
 
 
143
115
 
144
116
class TestHook(TestCase):
145
117