81
83
class TestTransportProviderAdapter(TestCase):
82
84
"""A group of tests that test the transport implementation adaption core.
86
This is a meta test that the tests are applied to all available
84
89
This will be generalised in the future which is why it is in this
85
90
test file even though it is specific to transport tests at the moment.
109
114
modules = _get_transport_modules()
110
115
permutation_count = 0
111
116
for module in modules:
112
permutation_count += len(reduce(getattr,
113
(module + ".get_test_permutations").split('.')[1:],
114
__import__(module))())
118
permutation_count += len(reduce(getattr,
119
(module + ".get_test_permutations").split('.')[1:],
120
__import__(module))())
121
except errors.DependencyNotPresent:
115
123
input_test = TestTransportProviderAdapter(
116
124
"test_adapter_sets_transport_class")
117
125
adapter = TransportTestProviderAdapter()
125
133
# that it does not just use the same one all the time.
126
134
# and that the id is set correctly so that debugging is
137
# An instance of this test is actually used as the input
138
# for adapting it to all the available transports
139
# (or i think so - ??? mbp)
128
140
from bzrlib.transport.local import (LocalTransport,
129
141
LocalRelpathServer,
130
142
LocalAbspathServer,
133
from bzrlib.transport.sftp import (SFTPTransport,
136
SFTPSiblingAbsoluteServer,
146
from bzrlib.transport.sftp import (SFTPTransport,
149
SFTPSiblingAbsoluteServer,
151
except errors.ParamikoNotPresent, e:
152
warnings.warn(str(e))
138
156
from bzrlib.transport.http import (HttpTransport,
159
177
input_test = TestTransportProviderAdapter(
160
178
"test_adapter_sets_transport_class")
161
179
suite = TransportTestProviderAdapter().adapt(input_test)
180
# tests are generated in collation order.
181
# XXX: but i'm not sure the order should really be part of the
182
# contract of the adapter, should it -- mbp 20060201
162
183
test_iter = iter(suite)
163
184
http_test = test_iter.next()
164
185
local_relpath_test = test_iter.next()
166
187
local_urlpath_test = test_iter.next()
167
188
memory_test = test_iter.next()
168
189
readonly_test = test_iter.next()
169
sftp_abs_test = test_iter.next()
170
sftp_homedir_test = test_iter.next()
171
sftp_sibling_abs_test = test_iter.next()
191
sftp_abs_test = test_iter.next()
192
sftp_homedir_test = test_iter.next()
193
sftp_sibling_abs_test = test_iter.next()
172
194
# ftp_test = test_iter.next()
195
# should now be at the end of the test
173
196
self.assertRaises(StopIteration, test_iter.next)
174
197
self.assertEqual(LocalTransport, local_relpath_test.transport_class)
175
198
self.assertEqual(LocalRelpathServer, local_relpath_test.transport_server)
180
203
self.assertEqual(LocalTransport, local_urlpath_test.transport_class)
181
204
self.assertEqual(LocalURLServer, local_urlpath_test.transport_server)
183
self.assertEqual(SFTPTransport, sftp_abs_test.transport_class)
184
self.assertEqual(SFTPAbsoluteServer, sftp_abs_test.transport_server)
185
self.assertEqual(SFTPTransport, sftp_homedir_test.transport_class)
186
self.assertEqual(SFTPHomeDirServer, sftp_homedir_test.transport_server)
187
self.assertEqual(SFTPTransport, sftp_sibling_abs_test.transport_class)
188
self.assertEqual(SFTPSiblingAbsoluteServer,
189
sftp_sibling_abs_test.transport_server)
207
self.assertEqual(SFTPTransport, sftp_abs_test.transport_class)
208
self.assertEqual(SFTPAbsoluteServer, sftp_abs_test.transport_server)
209
self.assertEqual(SFTPTransport, sftp_homedir_test.transport_class)
210
self.assertEqual(SFTPHomeDirServer, sftp_homedir_test.transport_server)
211
self.assertEqual(SFTPTransport, sftp_sibling_abs_test.transport_class)
212
self.assertEqual(SFTPSiblingAbsoluteServer,
213
sftp_sibling_abs_test.transport_server)
191
215
self.assertEqual(HttpTransport, http_test.transport_class)
192
216
self.assertEqual(HttpServer, http_test.transport_server)