~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Andrew Bennetts
  • Date: 2008-04-03 14:02:59 UTC
  • mfrom: (3331 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080403140259-83o949yopz03r40j
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
51
52
 
183
184
        self.assertTrue(result)
184
185
 
185
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
 
186
220
class TestBzrDirOpenBranch(tests.TestCase):
187
221
 
188
222
    def test_branch_present(self):