~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-02-06 01:45:28 UTC
  • mfrom: (3211.5.4 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080206014528-rb8v4hl04mgxulb7
(robertc) Tune RemoteRepository.get_parent_map to not send duplicate
        results, and to compress the data,
        reducing round trips further. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
These tests correspond to tests.test_smart, which exercises the server side.
24
24
"""
25
25
 
 
26
import bz2
26
27
from cStringIO import StringIO
27
28
 
28
29
from bzrlib import (
625
626
        r1 = u'\u0e33'.encode('utf8')
626
627
        r2 = u'\u0dab'.encode('utf8')
627
628
        lines = [' '.join([r2, r1]), r1]
628
 
        encoded_body = '\n'.join(lines)
 
629
        encoded_body = bz2.compress('\n'.join(lines))
629
630
        responses = [(('ok', ), encoded_body), (('ok', ), encoded_body)]
630
631
 
631
632
        transport_path = 'quack'
641
642
        parents = graph.get_parent_map([r1])
642
643
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
643
644
        self.assertEqual(
644
 
            [('call_expecting_body', 'Repository.get_parent_map',
645
 
             ('quack/', r2))],
 
645
            [('call_with_body_bytes_expecting_body',
 
646
              'Repository.get_parent_map', ('quack/', r2), '\n\n0')],
646
647
            client._calls)
647
648
        repo.unlock()
648
649
        # now we call again, and it should use the second response.
651
652
        parents = graph.get_parent_map([r1])
652
653
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
653
654
        self.assertEqual(
654
 
            [('call_expecting_body', 'Repository.get_parent_map',
655
 
              ('quack/', r2)),
656
 
             ('call_expecting_body', 'Repository.get_parent_map',
657
 
              ('quack/', r1))
 
655
            [('call_with_body_bytes_expecting_body',
 
656
              'Repository.get_parent_map', ('quack/', r2), '\n\n0'),
 
657
             ('call_with_body_bytes_expecting_body',
 
658
              'Repository.get_parent_map', ('quack/', r1), '\n\n0'),
658
659
            ],
659
660
            client._calls)
660
661
        repo.unlock()