~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_hooks.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-02-23 17:00:36 UTC
  • mfrom: (4032.1.4 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090223170036-3q1v68ewdt8i0to5
(Marius Kruger) Remove all trailing whitespace and add tests to
        enforce this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 
76
76
    def capture_set_rh_hook(self, branch, rev_history):
77
77
        """Capture post set-rh hook calls to self.hook_calls.
78
 
        
 
78
 
79
79
        The call is logged, as is some state of the branch.
80
80
        """
81
81
        self.hook_calls.append(
180
180
 
181
181
class TestPreChangeBranchTip(ChangeBranchTipTestCase):
182
182
    """Tests for pre_change_branch_tip hook.
183
 
    
 
183
 
184
184
    Most of these tests are very similar to the tests in
185
185
    TestPostChangeBranchTip.
186
186
    """
198
198
 
199
199
    def test_hook_failure_prevents_change(self):
200
200
        """If a hook raises an exception, the change does not take effect.
201
 
        
 
201
 
202
202
        Also, a HookFailed exception will be raised.
203
203
        """
204
204
        branch = self.make_branch_with_revision_ids(
214
214
        self.assertIsInstance(hook_failed_exc.exc_value, PearShapedError)
215
215
        # The revision info is unchanged.
216
216
        self.assertEqual((2, 'two-\xc2\xb5'), branch.last_revision_info())
217
 
        
 
217
 
218
218
    def test_empty_history(self):
219
219
        branch = self.make_branch('source')
220
220
        hook_calls = self.install_logging_hook('pre')
262
262
 
263
263
    def test_explicit_reject_by_hook(self):
264
264
        """If a hook raises TipChangeRejected, the change does not take effect.
265
 
        
 
265
 
266
266
        TipChangeRejected exceptions are propagated, not wrapped in HookFailed.
267
267
        """
268
268
        branch = self.make_branch_with_revision_ids(
275
275
            TipChangeRejected, branch.set_last_revision_info, 0, NULL_REVISION)
276
276
        # The revision info is unchanged.
277
277
        self.assertEqual((2, 'two-\xc2\xb5'), branch.last_revision_info())
278
 
        
 
278
 
279
279
 
280
280
class TestPostChangeBranchTip(ChangeBranchTipTestCase):
281
281
    """Tests for post_change_branch_tip hook.
350
350
    def setUp(self):
351
351
        ChangeBranchTipTestCase.setUp(self)
352
352
        self.installPreAndPostHooks()
353
 
        
 
353
 
354
354
    def installPreAndPostHooks(self):
355
355
        self.pre_hook_calls = self.install_logging_hook('pre')
356
356
        self.post_hook_calls = self.install_logging_hook('post')