/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 bzrlib/tests/test_remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-02-07 06:59:48 UTC
  • mfrom: (3213.1.8 request-body-recovery)
  • Revision ID: pqm@pqm.ubuntu.com-20080207065948-pjxwy4z6ljrpugj8
(andrew,
        #185394) Disconnect and reconnect the smart medium after getting
        unknown

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
        self.responses = responses
141
141
        self._calls = []
142
142
        self.expecting_body = False
143
 
        _SmartClient.__init__(self, FakeMedium(fake_medium_base))
 
143
        _SmartClient.__init__(self, FakeMedium(fake_medium_base, self._calls))
144
144
 
145
145
    def call(self, method, *args):
146
146
        self._calls.append(('call', method, args))
162
162
 
163
163
class FakeMedium(object):
164
164
 
165
 
    def __init__(self, base):
 
165
    def __init__(self, base, client_calls):
166
166
        self.base = base
 
167
        self.connection = FakeConnection(client_calls)
 
168
        self._client_calls = client_calls
 
169
 
 
170
 
 
171
class FakeConnection(object):
 
172
 
 
173
    def __init__(self, client_calls):
 
174
        self._remote_is_at_least_1_2 = True
 
175
        self._client_calls = client_calls
 
176
 
 
177
    def disconnect(self):
 
178
        self._client_calls.append(('disconnect medium',))
167
179
 
168
180
 
169
181
class TestVfsHas(tests.TestCase):
660
672
            client._calls)
661
673
        repo.unlock()
662
674
 
 
675
    def test_get_parent_map_reconnects_if_unknown_method(self):
 
676
        error_msg = (
 
677
            "Generic bzr smart protocol error: "
 
678
            "bad request 'Repository.get_parent_map'")
 
679
        responses = [
 
680
            (('error', error_msg), ''),
 
681
            (('ok',), '')]
 
682
        transport_path = 'quack'
 
683
        repo, client = self.setup_fake_client_and_repository(
 
684
            responses, transport_path)
 
685
        rev_id = 'revision-id'
 
686
        parents = repo.get_parent_map([rev_id])
 
687
        self.assertEqual(
 
688
            [('call_with_body_bytes_expecting_body',
 
689
              'Repository.get_parent_map', ('quack/', rev_id), '\n\n0'),
 
690
             ('disconnect medium',),
 
691
             ('call_expecting_body', 'Repository.get_revision_graph',
 
692
              ('quack/', ''))],
 
693
            client._calls)
 
694
 
 
695
 
663
696
 
664
697
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
665
698