/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: Robert Collins
  • Date: 2008-04-04 00:43:07 UTC
  • mfrom: (3331 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3333.
  • Revision ID: robertc@robertcollins.net-20080404004307-0whomfhm3yal2rvw
Resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
from bzrlib.revision import NULL_REVISION
46
46
from bzrlib.smart import server, medium
47
47
from bzrlib.smart.client import _SmartClient
 
48
from bzrlib.symbol_versioning import one_four
 
49
from bzrlib.transport import get_transport
48
50
from bzrlib.transport.memory import MemoryTransport
49
51
from bzrlib.transport.remote import RemoteTransport
50
52
 
55
57
        self.transport_server = server.SmartTCPServer_for_testing
56
58
        super(BasicRemoteObjectTests, self).setUp()
57
59
        self.transport = self.get_transport()
58
 
        self.client = self.transport.get_smart_client()
59
60
        # make a branch that can be opened over the smart transport
60
61
        self.local_wt = BzrDir.create_standalone_workingtree('.')
61
62
 
140
141
        self.responses = responses
141
142
        self._calls = []
142
143
        self.expecting_body = False
143
 
        _SmartClient.__init__(self, FakeMedium(fake_medium_base, self._calls))
 
144
        _SmartClient.__init__(self, FakeMedium(self._calls), fake_medium_base)
144
145
 
145
146
    def call(self, method, *args):
146
147
        self._calls.append(('call', method, args))
162
163
 
163
164
class FakeMedium(object):
164
165
 
165
 
    def __init__(self, base, client_calls):
166
 
        self.base = base
167
 
        self.connection = FakeConnection(client_calls)
168
 
        self._client_calls = client_calls
169
 
 
170
 
 
171
 
class FakeConnection(object):
172
 
 
173
166
    def __init__(self, client_calls):
174
167
        self._remote_is_at_least_1_2 = True
175
168
        self._client_calls = client_calls
191
184
        self.assertTrue(result)
192
185
 
193
186
 
 
187
class Test_SmartClient_remote_path_from_transport(tests.TestCase):
 
188
    """Tests for the behaviour of _SmartClient.remote_path_from_transport."""
 
189
 
 
190
    def assertRemotePath(self, expected, client_base, transport_base):
 
191
        """Assert that the result of _SmartClient.remote_path_from_transport
 
192
        is the expected value for a given client_base and transport_base.
 
193
        """
 
194
        dummy_medium = 'dummy medium'
 
195
        client = _SmartClient(dummy_medium, client_base)
 
196
        transport = get_transport(transport_base)
 
197
        result = client.remote_path_from_transport(transport)
 
198
        self.assertEqual(expected, result)
 
199
        
 
200
    def test_remote_path_from_transport(self):
 
201
        """_SmartClient.remote_path_from_transport calculates a URL for the
 
202
        given transport relative to the root of the client base URL.
 
203
        """
 
204
        self.assertRemotePath('xyz/', 'bzr://host/path', 'bzr://host/xyz')
 
205
        self.assertRemotePath(
 
206
            'path/xyz/', 'bzr://host/path', 'bzr://host/path/xyz')
 
207
 
 
208
    def test_remote_path_from_transport_http(self):
 
209
        """Remote paths for HTTP transports are calculated differently to other
 
210
        transports.  They are just relative to the client base, not the root
 
211
        directory of the host.
 
212
        """
 
213
        for scheme in ['http:', 'https:', 'bzr+http:', 'bzr+https:']:
 
214
            self.assertRemotePath(
 
215
                '../xyz/', scheme + '//host/path', scheme + '//host/xyz')
 
216
            self.assertRemotePath(
 
217
                'xyz/', scheme + '//host/path', scheme + '//host/path/xyz')
 
218
 
 
219
 
194
220
class TestBzrDirOpenBranch(tests.TestCase):
195
221
 
196
222
    def test_branch_present(self):
301
327
            input_file, output_file)
302
328
        return medium.SmartClientStreamMediumRequest(client_medium)
303
329
 
 
330
    def protocol_version(self):
 
331
        return 1
 
332
 
304
333
 
305
334
class OldServerTransport(object):
306
335
    """A fake transport for test_old_server that reports it's smart server
705
734
        transport_path = 'empty'
706
735
        repo, client = self.setup_fake_client_and_repository(
707
736
            responses, transport_path)
708
 
        result = repo.get_revision_graph(NULL_REVISION)
 
737
        result = self.applyDeprecated(one_four, repo.get_revision_graph,
 
738
            NULL_REVISION)
709
739
        self.assertEqual([], client._calls)
710
740
        self.assertEqual({}, result)
711
741
 
720
750
        transport_path = 'sinhala'
721
751
        repo, client = self.setup_fake_client_and_repository(
722
752
            responses, transport_path)
723
 
        result = repo.get_revision_graph()
 
753
        result = self.applyDeprecated(one_four, repo.get_revision_graph)
724
754
        self.assertEqual(
725
755
            [('call_expecting_body', 'Repository.get_revision_graph',
726
756
             ('sinhala/', ''))],
740
770
        transport_path = 'sinhala'
741
771
        repo, client = self.setup_fake_client_and_repository(
742
772
            responses, transport_path)
743
 
        result = repo.get_revision_graph(r2)
 
773
        result = self.applyDeprecated(one_four, repo.get_revision_graph, r2)
744
774
        self.assertEqual(
745
775
            [('call_expecting_body', 'Repository.get_revision_graph',
746
776
             ('sinhala/', r2))],
755
785
            responses, transport_path)
756
786
        # also check that the right revision is reported in the error
757
787
        self.assertRaises(errors.NoSuchRevision,
758
 
            repo.get_revision_graph, revid)
 
788
            self.applyDeprecated, one_four, repo.get_revision_graph, revid)
759
789
        self.assertEqual(
760
790
            [('call_expecting_body', 'Repository.get_revision_graph',
761
791
             ('sinhala/', revid))],