~bzr-pqm/bzr/bzr.dev

907.1.48 by John Arbash Meinel
Updated LocalTransport by passing it through the transport_test suite, and got it to pass.
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
1185.11.22 by John Arbash Meinel
Major refactoring of testtransport.
18
import os
1185.58.2 by John Arbash Meinel
Added mode to the appropriate transport functions, and tests to make sure they work.
19
import sys
1185.58.4 by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores.
20
import stat
1185.11.22 by John Arbash Meinel
Major refactoring of testtransport.
21
from cStringIO import StringIO
1442.1.44 by Robert Collins
Many transport related tweaks:
22
1185.50.13 by John Arbash Meinel
Expanded the Transport test suite. Including delete, copy, move, etc. Updated SftpTransport to conform.
23
from bzrlib.errors import (NoSuchFile, FileExists,
24
                           TransportNotPossible, ConnectionError)
1530.1.16 by Robert Collins
Move mkdir and copy_to permissions tests to test_transport_impleentation.
25
from bzrlib.tests import TestCase
1530.1.11 by Robert Collins
Push the transport permutations list into each transport module allowing for automatic testing of new modules that are registered as transports.
26
from bzrlib.transport import (_get_protocol_handlers,
27
                              _get_transport_modules,
28
                              register_lazy_transport,
29
                              _set_protocol_handlers,
30
                              urlescape,
31
                              )
1185.11.1 by John Arbash Meinel
(broken) Transport work is merged in. Tests do not pass yet.
32
1469 by Robert Collins
Change Transport.* to work with URL's.
33
1185.58.3 by John Arbash Meinel
code cleanup
34
class TestTransport(TestCase):
35
    """Test the non transport-concrete class functionality."""
36
37
    def test_urlescape(self):
38
        self.assertEqual('%25', urlescape('%'))
39
1530.1.11 by Robert Collins
Push the transport permutations list into each transport module allowing for automatic testing of new modules that are registered as transports.
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
            
1469 by Robert Collins
Change Transport.* to work with URL's.
63
1530.1.5 by Robert Collins
Reinstate Memory parameter tests.
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())