~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-01-13 06:31:42 UTC
  • Revision ID: mbp@sourcefrog.net-20060113063142-8e706dc1483c69e1
Bump version to 0.8pre

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2004, 2005 by Canonical Ltd
 
2
 
 
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.
 
7
 
 
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.
 
12
 
 
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
 
16
 
 
17
 
 
18
import os
 
19
import sys
 
20
import stat
 
21
from cStringIO import StringIO
 
22
 
 
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,
 
30
                              urlescape,
 
31
                              )
 
32
 
 
33
 
 
34
class TestTransport(TestCase):
 
35
    """Test the non transport-concrete class functionality."""
 
36
 
 
37
    def test_urlescape(self):
 
38
        self.assertEqual('%25', urlescape('%'))
 
39
 
 
40
    def test__get_set_protocol_handlers(self):
 
41
        handlers = _get_protocol_handlers()
 
42
        self.assertNotEqual({}, handlers)
 
43
        try:
 
44
            _set_protocol_handlers({})
 
45
            self.assertEqual({}, _get_protocol_handlers())
 
46
        finally:
 
47
            _set_protocol_handlers(handlers)
 
48
 
 
49
    def test_get_transport_modules(self):
 
50
        handlers = _get_protocol_handlers()
 
51
        class SampleHandler(object):
 
52
            """I exist, isnt that enough?"""
 
53
        try:
 
54
            my_handlers = {}
 
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())
 
60
        finally:
 
61
            _set_protocol_handlers(handlers)
 
62
            
 
63
 
 
64
class MemoryTransportTest(TestCase):
 
65
    """Memory transport specific tests."""
 
66
 
 
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())