/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/per_branch/test_hooks.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    )
28
28
from breezy.tests import test_server
29
29
 
 
30
 
30
31
class ChangeBranchTipTestCase(tests.TestCaseWithMemoryTransport):
31
32
    """Base TestCase for testing pre/post_change_branch_tip hooks."""
32
33
 
53
54
        return branch
54
55
 
55
56
    def assertHookCalls(self, expected_params, branch, hook_calls=None,
56
 
        pre=False):
 
57
                        pre=False):
57
58
        if hook_calls is None:
58
59
            hook_calls = self.hook_calls
59
60
        if isinstance(branch, remote.RemoteBranch):
87
88
        if isinstance(b, remote.RemoteBranch):
88
89
            # RemoteBranch creation:
89
90
            if (self.transport_readonly_server
90
 
                == test_server.ReadonlySmartTCPServer_for_testing_v2_only):
 
91
                    == test_server.ReadonlySmartTCPServer_for_testing_v2_only):
91
92
                # Older servers:
92
93
                self.assertEqual(3, len(self.hook_calls))
93
94
                # creates the branch via the VFS (for older servers)
138
139
        """The hook runs *before* the branch's last_revision_info has changed.
139
140
        """
140
141
        branch = self.make_branch_with_revision_ids(b'revid-one')
 
142
 
141
143
        def assertBranchAtRevision1(params):
142
144
            self.assertEqual(
143
145
                (1, b'revid-one'), params.branch.last_revision_info())
149
151
        """If a hook raises an exception, the change does not take effect."""
150
152
        branch = self.make_branch_with_revision_ids(
151
153
            b'one-\xc2\xb5', b'two-\xc2\xb5')
 
154
 
152
155
        class PearShapedError(Exception):
153
156
            pass
 
157
 
154
158
        def hook_that_raises(params):
155
159
            raise PearShapedError()
156
160
        _mod_branch.Branch.hooks.install_named_hook(
183
187
 
184
188
    def test_branch_is_locked(self):
185
189
        branch = self.make_branch('source')
 
190
 
186
191
        def assertBranchIsLocked(params):
187
192
            self.assertTrue(params.branch.is_locked())
188
193
        _mod_branch.Branch.hooks.install_named_hook(
213
218
        """
214
219
        branch = self.make_branch_with_revision_ids(
215
220
            b'one-\xc2\xb5', b'two-\xc2\xb5')
 
221
 
216
222
        def hook_that_rejects(params):
217
223
            raise errors.TipChangeRejected('rejection message')
218
224
        _mod_branch.Branch.hooks.install_named_hook(
235
241
        """The hook runs *after* the branch's last_revision_info has changed.
236
242
        """
237
243
        branch = self.make_branch_with_revision_ids(b'revid-one')
 
244
 
238
245
        def assertBranchAtRevision1(params):
239
246
            self.assertEqual(
240
247
                (0, revision.NULL_REVISION), params.branch.last_revision_info())
265
272
    def test_branch_is_locked(self):
266
273
        """The branch passed to the hook is locked."""
267
274
        branch = self.make_branch('source')
 
275
 
268
276
        def assertBranchIsLocked(params):
269
277
            self.assertTrue(params.branch.is_locked())
270
278
        _mod_branch.Branch.hooks.install_named_hook(