~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: Martin Pool
  • Date: 2006-11-02 10:20:19 UTC
  • mfrom: (2114 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2119.
  • Revision ID: mbp@sourcefrog.net-20061102102019-9a5a02f485dff6f6
merge bzr.dev and reconcile several changes, also some test fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2004, 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
from cStringIO import StringIO
22
22
 
23
23
import bzrlib
 
24
from bzrlib import urlutils
24
25
from bzrlib.errors import (NoSuchFile, FileExists,
25
26
                           TransportNotPossible,
26
27
                           ConnectionError,
40
41
from bzrlib.transport.local import LocalTransport
41
42
 
42
43
 
 
44
# TODO: Should possibly split transport-specific tests into their own files.
 
45
 
 
46
 
43
47
class TestTransport(TestCase):
44
48
    """Test the non transport-concrete class functionality."""
45
49
 
100
104
        finally:
101
105
            _set_protocol_handlers(saved_handlers)
102
106
 
 
107
    def test__combine_paths(self):
 
108
        t = Transport('/')
 
109
        self.assertEqual('/home/sarah/project/foo',
 
110
                         t._combine_paths('/home/sarah', 'project/foo'))
 
111
        self.assertEqual('/etc',
 
112
                         t._combine_paths('/home/sarah', '../../etc'))
 
113
        self.assertEqual('/etc',
 
114
                         t._combine_paths('/home/sarah', '../../../etc'))
 
115
        self.assertEqual('/etc',
 
116
                         t._combine_paths('/home/sarah', '/etc'))
 
117
 
103
118
 
104
119
class TestCoalesceOffsets(TestCase):
105
120
    
179
194
        self.assertEqual("memory:///", transport.base)
180
195
        self.assertEqual("memory:///", transport.abspath('/'))
181
196
 
182
 
    def test_relpath(self):
 
197
    def test_abspath_of_relpath_starting_at_root(self):
183
198
        transport = MemoryTransport()
 
199
        self.assertEqual("memory:///foo", transport.abspath('/foo'))
184
200
 
185
201
    def test_append_and_get(self):
186
202
        transport = MemoryTransport()
325
341
        server = fakenfs.FakeNFSServer()
326
342
        server.setUp()
327
343
        try:
328
 
            # the server should be a relpath localhost server
329
 
            self.assertEqual(server.get_url(), 'fakenfs+.')
 
344
            # the url should be decorated appropriately
 
345
            self.assertStartsWith(server.get_url(), 'fakenfs+')
330
346
            # and we should be able to get a transport for it
331
347
            transport = get_transport(server.get_url())
332
348
            # which must be a FakeNFSTransportDecorator instance.
420
436
            # regular connection behaviour by direct construction.
421
437
            t = self.transport_class(base_url)
422
438
        return t
 
439
 
 
440
 
 
441
class TestLocalTransports(TestCase):
 
442
 
 
443
    def test_get_transport_from_abspath(self):
 
444
        here = os.path.abspath('.')
 
445
        t = get_transport(here)
 
446
        self.assertIsInstance(t, LocalTransport)
 
447
        self.assertEquals(t.base, urlutils.local_path_to_url(here) + '/')
 
448
 
 
449
    def test_get_transport_from_relpath(self):
 
450
        here = os.path.abspath('.')
 
451
        t = get_transport('.')
 
452
        self.assertIsInstance(t, LocalTransport)
 
453
        self.assertEquals(t.base, urlutils.local_path_to_url('.') + '/')
 
454
 
 
455
    def test_get_transport_from_local_url(self):
 
456
        here = os.path.abspath('.')
 
457
        here_url = urlutils.local_path_to_url(here) + '/'
 
458
        t = get_transport(here_url)
 
459
        self.assertIsInstance(t, LocalTransport)
 
460
        self.assertEquals(t.base, here_url)