~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2008-09-23 03:21:07 UTC
  • mto: This revision was merged to the branch mainline in revision 3725.
  • Revision ID: robertc@robertcollins.net-20080923032107-ibt7hdhdwcanbvvp
Update branch open tests to accomodate stacking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests that branch classes implement hook callouts correctly."""
18
18
 
 
19
from bzrlib.branch import Branch, ChangeBranchTipParams
19
20
from bzrlib.errors import HookFailed, TipChangeRejected
20
 
from bzrlib.branch import Branch, ChangeBranchTipParams
 
21
from bzrlib.remote import RemoteBranch
21
22
from bzrlib.revision import NULL_REVISION
22
23
from bzrlib.tests import TestCaseWithMemoryTransport
23
24
 
125
126
        branch_url = self.make_branch('.').bzrdir.root_transport.base
126
127
        self.install_hook()
127
128
        b = Branch.open(branch_url)
128
 
        self.assertEqual([b], self.hook_calls)
 
129
        if isinstance(b, RemoteBranch):
 
130
            # RemoteBranch open always opens the backing branch to get stacking
 
131
            # details. As that is done remotely we can't see the branch object
 
132
            # nor even compare base url's etc. So we just assert that the first
 
133
            # branch returned is the RemoteBranch, and that the second is a
 
134
            # Branch but not a RemoteBranch.
 
135
            self.assertEqual(2, len(self.hook_calls))
 
136
            self.assertEqual(b, self.hook_calls[0])
 
137
            self.assertIsInstance(self.hook_calls[1], Branch)
 
138
            self.assertFalse(isinstance(self.hook_calls[1], RemoteBranch))
 
139
        else:
 
140
            self.assertEqual([b], self.hook_calls)
129
141
 
130
142
 
131
143
class TestPreChangeBranchTip(ChangeBranchTipTestCase):