/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 breezy/tests/blackbox/test_hooks.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2011, 2012, 2016 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 commands related to hooks"""
18
18
 
19
 
from bzrlib.branch import Branch
20
 
from bzrlib.tests import TestCaseWithTransport
 
19
from breezy.branch import Branch
 
20
from breezy.tests import TestCaseWithTransport
 
21
 
21
22
 
22
23
def _foo_hook():
23
24
    pass
24
25
 
 
26
 
25
27
class TestHooks(TestCaseWithTransport):
26
28
 
27
29
    def _check_hooks_output(self, command_output, hooks):
28
30
        for hook_type in Branch.hooks:
29
31
            s = "\n  ".join(hooks.get(hook_type, ["<no hooks installed>"]))
30
 
            self.assert_("%s:\n    %s" % (hook_type, s) in command_output)
 
32
            self.assertTrue("%s:\n    %s" % (hook_type, s) in command_output)
31
33
 
32
34
    def test_hooks_with_no_hooks(self):
33
35
        self.make_branch('.')
38
40
 
39
41
    def test_hooks_with_unnamed_hook(self):
40
42
        self.make_branch('.')
 
43
 
41
44
        def foo(): return
42
45
        Branch.hooks.install_named_hook('post_push', foo, None)
43
46
        out, err = self.run_bzr('hooks')
45
48
 
46
49
    def test_hooks_with_named_hook(self):
47
50
        self.make_branch('.')
 
51
 
48
52
        def foo(): return
49
53
        name = "Foo Bar Hook"
50
54
        Branch.hooks.install_named_hook('post_push', foo, name)
56
60
 
57
61
    def test_hooks_lazy_with_unnamed_hook(self):
58
62
        self.make_branch('.')
 
63
 
59
64
        def foo(): return
60
65
        Branch.hooks.install_named_hook_lazy('post_push',
61
 
            'bzrlib.tests.blackbox.test_hooks',
62
 
            '_foo_hook',
63
 
            None)
 
66
                                             'breezy.tests.blackbox.test_hooks',
 
67
                                             '_foo_hook',
 
68
                                             None)
64
69
        out, err = self.run_bzr('hooks')
65
70
        self._check_hooks_output(out, {'post_push': ["No hook name"]})
66
 
        
 
71
 
67
72
    def test_hooks_lazy_with_named_hook(self):
68
73
        self.make_branch('.')
 
74
 
69
75
        def foo(): return
70
76
        Branch.hooks.install_named_hook_lazy('post_push',
71
 
            'bzrlib.tests.blackbox.test_hooks',
72
 
            '_foo_hook',
73
 
            'hook has a name')
 
77
                                             'breezy.tests.blackbox.test_hooks',
 
78
                                             '_foo_hook',
 
79
                                             'hook has a name')
74
80
        out, err = self.run_bzr('hooks')
75
81
        self._check_hooks_output(out, {'post_push': ["hook has a name"]})