/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-12 18:05:15 UTC
  • mto: (4371.4.5 vila-better-heads)
  • mto: This revision was merged to the branch mainline in revision 4449.
  • Revision ID: john@arbash-meinel.com-20090612180515-t0cwbjsnve094oik
Add a failing test for handling nodes that are in the same linear chain.

It fails because the ancestry skipping causes us to miss the fact that the two nodes
are actually directly related. We could check at the beginning, as the 
code used to do, but I think that will be incomplete for the more-than-two
heads cases.

Show diffs side-by-side

added added

removed removed

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