1
# Copyright (C) 2004, 2005 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
from cStringIO import StringIO
23
from bzrlib.errors import (NoSuchFile, FileExists,
24
TransportNotPossible, ConnectionError)
25
from bzrlib.tests import TestCase
26
from bzrlib.transport import (_get_protocol_handlers,
27
_get_transport_modules,
28
register_lazy_transport,
29
_set_protocol_handlers,
34
class TestTransport(TestCase):
35
"""Test the non transport-concrete class functionality."""
37
def test_urlescape(self):
38
self.assertEqual('%25', urlescape('%'))
40
def test__get_set_protocol_handlers(self):
41
handlers = _get_protocol_handlers()
42
self.assertNotEqual({}, handlers)
44
_set_protocol_handlers({})
45
self.assertEqual({}, _get_protocol_handlers())
47
_set_protocol_handlers(handlers)
49
def test_get_transport_modules(self):
50
handlers = _get_protocol_handlers()
51
class SampleHandler(object):
52
"""I exist, isnt that enough?"""
55
_set_protocol_handlers(my_handlers)
56
register_lazy_transport('foo', 'bzrlib.tests.test_transport', 'TestTransport.SampleHandler')
57
register_lazy_transport('bar', 'bzrlib.tests.test_transport', 'TestTransport.SampleHandler')
58
self.assertEqual([SampleHandler.__module__],
59
_get_transport_modules())
61
_set_protocol_handlers(handlers)
64
class MemoryTransportTest(TestCase):
65
"""Memory transport specific tests."""
67
def test_parameters(self):
68
import bzrlib.transport.memory as memory
69
transport = memory.MemoryTransport()
70
self.assertEqual(True, transport.listable())
71
self.assertEqual(False, transport.should_cache())
72
self.assertEqual(False, transport.is_readonly())