~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2007-2010 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
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()
95
94
 
96
95
    def test_install_named_hook_raises_unknown_hook(self):
97
96
        hooks = Hooks()
98
 
        self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
 
97
        self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly',
99
98
                          None, "")
100
99
 
101
100
    def test_install_named_hook_appends_known_hook(self):
111
110
        self.assertEqual("demo", hooks.get_hook_name(None))
112
111
 
113
112
 
114
 
class TestHook(TestCase):
 
113
class TestHook(tests.TestCase):
115
114
 
116
115
    def test___init__(self):
117
116
        doc = ("Invoked after changing the tip of a branch object. Called with"
154
153
            callback_repr, repr(hook))
155
154
 
156
155
 
157
 
class TestHookRegistry(TestCase):
 
156
class TestHookRegistry(tests.TestCase):
158
157
 
159
158
    def test_items_are_reasonable_keys(self):
160
159
        # All the items in the known_hooks registry need to map from
170
169
            new_hooks = factory()
171
170
            self.assertIsInstance(obj, Hooks)
172
171
            self.assertEqual(type(obj), type(new_hooks))
 
172
            self.assertEqual("No hook name", new_hooks.get_hook_name(None))
173
173
 
174
174
    def test_known_hooks_key_to_object(self):
175
175
        self.assertIs(branch.Branch.hooks,