20
20
from bzrlib.tests import TestCaseWithMemoryTransport
23
class TestPushHook(TestCaseWithMemoryTransport):
23
class TestSetRevisionHistoryHook(TestCaseWithMemoryTransport):
26
26
self.hook_calls = []
27
27
TestCaseWithMemoryTransport.setUp(self)
29
29
def capture_set_rh_hook(self, branch, rev_history):
30
"""Capture post push hook calls to self.hook_calls.
30
"""Capture post set-rh hook calls to self.hook_calls.
32
The call is logged, as is some state of the two branches.
32
The call is logged, as is some state of the branch.
34
34
self.hook_calls.append(
35
35
('set_rh', branch, rev_history, branch.is_locked()))
37
37
def test_set_rh_empty_history(self):
38
38
branch = self.make_branch('source')
39
Branch.hooks['set_rh'].append(self.capture_set_rh_hook)
39
Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
40
40
branch.set_revision_history([])
41
41
self.assertEqual(self.hook_calls,
42
42
[('set_rh', branch, [], True)])
44
44
def test_set_rh_nonempty_history(self):
45
45
branch = self.make_branch('source')
46
Branch.hooks['set_rh'].append(self.capture_set_rh_hook)
46
Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
47
47
branch.set_revision_history([u'foo'])
48
48
self.assertEqual(self.hook_calls,
49
49
[('set_rh', branch, [u'foo'], True)])
51
51
def test_set_rh_branch_is_locked(self):
52
52
branch = self.make_branch('source')
53
Branch.hooks['set_rh'].append(self.capture_set_rh_hook)
53
Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
54
54
branch.set_revision_history([])
55
55
self.assertEqual(self.hook_calls,
56
56
[('set_rh', branch, [], True)])
58
58
def test_set_rh_calls_all_hooks_no_errors(self):
59
59
branch = self.make_branch('source')
60
Branch.hooks['set_rh'].append(self.capture_set_rh_hook)
61
Branch.hooks['set_rh'].append(self.capture_set_rh_hook)
60
Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
61
Branch.hooks.install_hook('set_rh', self.capture_set_rh_hook)
62
62
branch.set_revision_history([])
63
63
self.assertEqual(self.hook_calls,
64
64
[('set_rh', branch, [], True),
65
65
('set_rh', branch, [], True),