/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: Andrew Bennetts
  • Date: 2008-02-07 03:47:24 UTC
  • mfrom: (3218 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3220.
  • Revision ID: andrew.bennetts@canonical.com-20080207034724-p3zhr7zp9kow4nax
Merge from bzr.dev.

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 (
218
219
            [('call', 'BzrDir.open_branch', ('quack/',))],
219
220
            client._calls)
220
221
 
 
222
    def test__get_tree_branch(self):
 
223
        # _get_tree_branch is a form of open_branch, but it should only ask for
 
224
        # branch opening, not any other network requests.
 
225
        calls = []
 
226
        def open_branch():
 
227
            calls.append("Called")
 
228
            return "a-branch"
 
229
        transport = MemoryTransport()
 
230
        # no requests on the network - catches other api calls being made.
 
231
        client = FakeClient([], transport.base)
 
232
        bzrdir = RemoteBzrDir(transport, _client=client)
 
233
        # patch the open_branch call to record that it was called.
 
234
        bzrdir.open_branch = open_branch
 
235
        self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch())
 
236
        self.assertEqual(["Called"], calls)
 
237
        self.assertEqual([], client._calls)
 
238
 
221
239
    def test_url_quoting_of_path(self):
222
240
        # Relpaths on the wire should not be URL-escaped.  So "~" should be
223
241
        # transmitted as "~", not "%7E".
620
638
        r1 = u'\u0e33'.encode('utf8')
621
639
        r2 = u'\u0dab'.encode('utf8')
622
640
        lines = [' '.join([r2, r1]), r1]
623
 
        encoded_body = '\n'.join(lines)
 
641
        encoded_body = bz2.compress('\n'.join(lines))
624
642
        responses = [(('ok', ), encoded_body), (('ok', ), encoded_body)]
625
643
 
626
644
        transport_path = 'quack'
636
654
        parents = graph.get_parent_map([r1])
637
655
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
638
656
        self.assertEqual(
639
 
            [('call_expecting_body', 'Repository.get_parent_map',
640
 
             ('quack/', r2))],
 
657
            [('call_with_body_bytes_expecting_body',
 
658
              'Repository.get_parent_map', ('quack/', r2), '\n\n0')],
641
659
            client._calls)
642
660
        repo.unlock()
643
661
        # now we call again, and it should use the second response.
646
664
        parents = graph.get_parent_map([r1])
647
665
        self.assertEqual({r1: (NULL_REVISION,)}, parents)
648
666
        self.assertEqual(
649
 
            [('call_expecting_body', 'Repository.get_parent_map',
650
 
              ('quack/', r2)),
651
 
             ('call_expecting_body', 'Repository.get_parent_map',
652
 
              ('quack/', r1))
 
667
            [('call_with_body_bytes_expecting_body',
 
668
              'Repository.get_parent_map', ('quack/', r2), '\n\n0'),
 
669
             ('call_with_body_bytes_expecting_body',
 
670
              'Repository.get_parent_map', ('quack/', r1), '\n\n0'),
653
671
            ],
654
672
            client._calls)
655
673
        repo.unlock()
667
685
        rev_id = 'revision-id'
668
686
        parents = repo.get_parent_map([rev_id])
669
687
        self.assertEqual(
670
 
            [('call_expecting_body', 'Repository.get_parent_map',
671
 
             ('quack/', rev_id)),
 
688
            [('call_with_body_bytes_expecting_body',
 
689
              'Repository.get_parent_map', ('quack/', rev_id), '\n\n0'),
672
690
             ('disconnect medium',),
673
691
             ('call_expecting_body', 'Repository.get_revision_graph',
674
692
              ('quack/', ''))],