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, |
|
1534.4.9
by Robert Collins
Add a readonly decorator for transports. |
28 |
get_transport, |
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. |
29 |
register_lazy_transport, |
30 |
_set_protocol_handlers, |
|
31 |
urlescape, |
|
32 |
)
|
|
1185.11.1
by John Arbash Meinel
(broken) Transport work is merged in. Tests do not pass yet. |
33 |
|
1469
by Robert Collins
Change Transport.* to work with URL's. |
34 |
|
1185.58.3
by John Arbash Meinel
code cleanup |
35 |
class TestTransport(TestCase): |
36 |
"""Test the non transport-concrete class functionality."""
|
|
37 |
||
38 |
def test_urlescape(self): |
|
39 |
self.assertEqual('%25', urlescape('%')) |
|
40 |
||
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. |
41 |
def test__get_set_protocol_handlers(self): |
42 |
handlers = _get_protocol_handlers() |
|
43 |
self.assertNotEqual({}, handlers) |
|
44 |
try: |
|
45 |
_set_protocol_handlers({}) |
|
46 |
self.assertEqual({}, _get_protocol_handlers()) |
|
47 |
finally: |
|
48 |
_set_protocol_handlers(handlers) |
|
49 |
||
50 |
def test_get_transport_modules(self): |
|
51 |
handlers = _get_protocol_handlers() |
|
52 |
class SampleHandler(object): |
|
53 |
"""I exist, isnt that enough?"""
|
|
54 |
try: |
|
55 |
my_handlers = {} |
|
56 |
_set_protocol_handlers(my_handlers) |
|
57 |
register_lazy_transport('foo', 'bzrlib.tests.test_transport', 'TestTransport.SampleHandler') |
|
58 |
register_lazy_transport('bar', 'bzrlib.tests.test_transport', 'TestTransport.SampleHandler') |
|
59 |
self.assertEqual([SampleHandler.__module__], |
|
60 |
_get_transport_modules()) |
|
61 |
finally: |
|
62 |
_set_protocol_handlers(handlers) |
|
63 |
||
1469
by Robert Collins
Change Transport.* to work with URL's. |
64 |
|
1530.1.5
by Robert Collins
Reinstate Memory parameter tests. |
65 |
class MemoryTransportTest(TestCase): |
66 |
"""Memory transport specific tests."""
|
|
67 |
||
68 |
def test_parameters(self): |
|
69 |
import bzrlib.transport.memory as memory |
|
70 |
transport = memory.MemoryTransport() |
|
71 |
self.assertEqual(True, transport.listable()) |
|
72 |
self.assertEqual(False, transport.should_cache()) |
|
73 |
self.assertEqual(False, transport.is_readonly()) |
|
1534.4.9
by Robert Collins
Add a readonly decorator for transports. |
74 |
|
75 |
||
76 |
class ReadonlyDecoratorTransportTest(TestCase): |
|
77 |
"""Readonly decoration specific tests."""
|
|
78 |
||
79 |
def test_local_parameters(self): |
|
80 |
import bzrlib.transport.readonly as readonly |
|
81 |
# connect to . in readonly mode
|
|
82 |
transport = readonly.ReadonlyTransportDecorator('readonly+.') |
|
83 |
self.assertEqual(True, transport.listable()) |
|
84 |
self.assertEqual(False, transport.should_cache()) |
|
85 |
self.assertEqual(True, transport.is_readonly()) |
|
86 |
||
87 |
def test_http_parameters(self): |
|
88 |
import bzrlib.transport.readonly as readonly |
|
89 |
from bzrlib.transport.http import HttpServer |
|
90 |
# connect to . via http which is not listable
|
|
91 |
server = HttpServer() |
|
92 |
server.setUp() |
|
93 |
try: |
|
94 |
transport = get_transport('readonly+' + server.get_url()) |
|
95 |
self.failUnless(isinstance(transport, |
|
96 |
readonly.ReadonlyTransportDecorator)) |
|
97 |
self.assertEqual(False, transport.listable()) |
|
98 |
self.assertEqual(True, transport.should_cache()) |
|
99 |
self.assertEqual(True, transport.is_readonly()) |
|
100 |
finally: |
|
101 |
server.tearDown() |