~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-18 01:16:25 UTC
  • mfrom: (3184.1.13 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080118011625-465mgy0mhdz1jiky
(robertc) Reduce traffic when requesting revision streams from a
        smart server (3 MB to 172 bytes for a full bzr.dev pull)
        (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib import (
29
29
    bzrdir,
30
30
    errors,
 
31
    graph,
31
32
    pack,
32
33
    remote,
33
34
    repository,
151
152
        self.expecting_body = True
152
153
        return result[0], FakeProtocol(result[1], self)
153
154
 
 
155
    def call_with_body_bytes_expecting_body(self, method, args, body):
 
156
        self._calls.append(('call_with_body_bytes_expecting_body', method,
 
157
            args, body))
 
158
        result = self.responses.pop(0)
 
159
        self.expecting_body = True
 
160
        return result[0], FakeProtocol(result[1], self)
 
161
 
154
162
 
155
163
class FakeMedium(object):
156
164
 
867
875
        transport_path = 'quack'
868
876
        repo, client = self.setup_fake_client_and_repository(
869
877
            responses, transport_path)
870
 
        stream = repo.get_data_stream(['revid'])
 
878
        search = graph.SearchResult(set(['revid']), set(), 1, set(['revid']))
 
879
        stream = repo.get_data_stream_for_search(search)
871
880
        self.assertRaises(errors.SmartProtocolError, list, stream)
872
881
    
873
882
    def test_backwards_compatibility(self):
881
890
            responses, 'path')
882
891
        self.mock_called = False
883
892
        repo._real_repository = MockRealRepository(self)
884
 
        repo.get_data_stream(['revid'])
 
893
        search = graph.SearchResult(set(['revid']), set(), 1, set(['revid']))
 
894
        repo.get_data_stream_for_search(search)
885
895
        self.assertTrue(self.mock_called)
886
896
        self.failIf(client.expecting_body,
887
897
            "The protocol has been left in an unclean state that will cause "
894
904
    def __init__(self, test):
895
905
        self.test = test
896
906
 
897
 
    def get_data_stream(self, revision_ids):
898
 
        self.test.assertEqual(['revid'], revision_ids)
 
907
    def get_data_stream_for_search(self, search):
 
908
        self.test.assertEqual(set(['revid']), search.get_keys())
899
909
        self.test.mock_called = True
900
910
 
901
911