46
46
from bzrlib.smart import server, medium
47
47
from bzrlib.smart.client import _SmartClient
48
48
from bzrlib.symbol_versioning import one_four
49
from bzrlib.transport import get_transport
49
50
from bzrlib.transport.memory import MemoryTransport
50
51
from bzrlib.transport.remote import RemoteTransport
183
184
self.assertTrue(result)
187
class Test_SmartClient_remote_path_from_transport(tests.TestCase):
188
"""Tests for the behaviour of _SmartClient.remote_path_from_transport."""
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.
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)
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.
204
self.assertRemotePath('xyz/', 'bzr://host/path', 'bzr://host/xyz')
205
self.assertRemotePath(
206
'path/xyz/', 'bzr://host/path', 'bzr://host/path/xyz')
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.
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')
186
220
class TestBzrDirOpenBranch(tests.TestCase):
188
222
def test_branch_present(self):