bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
1  | 
# Copyright (C) 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 version 2 as published by
 | 
|
5  | 
# the Free Software Foundation.
 | 
|
6  | 
#
 | 
|
7  | 
# This program is distributed in the hope that it will be useful,
 | 
|
8  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
9  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
10  | 
# GNU General Public License for more details.
 | 
|
11  | 
#
 | 
|
12  | 
# You should have received a copy of the GNU General Public License
 | 
|
13  | 
# along with this program; if not, write to the Free Software
 | 
|
14  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
15  | 
||
16  | 
"""Tests for the test framework
 | 
|
17  | 
"""
 | 
|
18  | 
||
19  | 
import os  | 
|
20  | 
import sys  | 
|
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
21  | 
import unittest  | 
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
22  | 
import warnings  | 
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
23  | 
|
| 
1534.4.25
by Robert Collins
 Add a --transport parameter to the test suite to set the default transport to be used in the test suite.  | 
24  | 
import bzrlib  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
25  | 
from bzrlib.tests import (  | 
26  | 
_load_module_by_name,  | 
|
| 
1534.4.31
by Robert Collins
 cleanedup test_outside_wt  | 
27  | 
ChrootedTestCase,  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
28  | 
TestCase,  | 
29  | 
TestCaseInTempDir,  | 
|
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
30  | 
TestCaseWithTransport,  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
31  | 
TestSkipped,  | 
32  | 
TextTestRunner,  | 
|
33  | 
                          )
 | 
|
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
34  | 
import bzrlib.errors as errors  | 
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
35  | 
|
36  | 
||
37  | 
class SelftestTests(TestCase):  | 
|
38  | 
||
39  | 
def test_import_tests(self):  | 
|
40  | 
mod = _load_module_by_name('bzrlib.tests.test_selftest')  | 
|
41  | 
self.assertEqual(mod.SelftestTests, SelftestTests)  | 
|
42  | 
||
43  | 
def test_import_test_failure(self):  | 
|
44  | 
self.assertRaises(ImportError,  | 
|
45  | 
_load_module_by_name,  | 
|
46  | 
'bzrlib.no-name-yet')  | 
|
47  | 
||
48  | 
||
49  | 
class MetaTestLog(TestCase):  | 
|
| 
1526.1.1
by Robert Collins
 Run the test suite with no locale as well as the default locale. Also add a test for build_tree_shape to selftest.  | 
50  | 
|
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
51  | 
def test_logging(self):  | 
52  | 
"""Test logs are captured when a test fails."""  | 
|
53  | 
self.log('a test message')  | 
|
54  | 
self._log_file.flush()  | 
|
55  | 
self.assertContainsRe(self._get_log(), 'a test message\n')  | 
|
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
56  | 
|
57  | 
||
| 
1526.1.1
by Robert Collins
 Run the test suite with no locale as well as the default locale. Also add a test for build_tree_shape to selftest.  | 
58  | 
class TestTreeShape(TestCaseInTempDir):  | 
59  | 
||
60  | 
def test_unicode_paths(self):  | 
|
61  | 
filename = u'hell\u00d8'  | 
|
| 
1526.1.4
by Robert Collins
 forgot my self.  | 
62  | 
try:  | 
63  | 
self.build_tree_contents([(filename, 'contents of hello')])  | 
|
64  | 
except UnicodeEncodeError:  | 
|
65  | 
raise TestSkipped("can't build unicode working tree in "  | 
|
66  | 
"filesystem encoding %s" % sys.getfilesystemencoding())  | 
|
| 
1526.1.1
by Robert Collins
 Run the test suite with no locale as well as the default locale. Also add a test for build_tree_shape to selftest.  | 
67  | 
self.failUnlessExists(filename)  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
68  | 
|
69  | 
||
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
70  | 
class TestSkippedTest(TestCase):  | 
71  | 
"""Try running a test which is skipped, make sure it's reported properly."""  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
72  | 
|
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
73  | 
def test_skipped_test(self):  | 
74  | 
        # must be hidden in here so it's not run as a real test
 | 
|
75  | 
def skipping_test():  | 
|
76  | 
raise TestSkipped('test intentionally skipped')  | 
|
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
77  | 
runner = TextTestRunner(stream=self._log_file)  | 
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
78  | 
test = unittest.FunctionTestCase(skipping_test)  | 
79  | 
result = runner.run(test)  | 
|
80  | 
self.assertTrue(result.wasSuccessful())  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
81  | 
|
82  | 
||
83  | 
class TestTransportProviderAdapter(TestCase):  | 
|
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
84  | 
"""A group of tests that test the transport implementation adaption core.  | 
85  | 
||
| 
1551.1.1
by Martin Pool
 [merge] branch-formats branch, and reconcile changes  | 
86  | 
    This is a meta test that the tests are applied to all available 
 | 
87  | 
    transports.
 | 
|
88  | 
||
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
89  | 
    This will be generalised in the future which is why it is in this 
 | 
90  | 
    test file even though it is specific to transport tests at the moment.
 | 
|
91  | 
    """
 | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
92  | 
|
| 
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.  | 
93  | 
def test_get_transport_permutations(self):  | 
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
94  | 
        # this checks that we the module get_test_permutations call
 | 
95  | 
        # is made by the adapter get_transport_test_permitations method.
 | 
|
| 
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.  | 
96  | 
class MockModule(object):  | 
97  | 
def get_test_permutations(self):  | 
|
98  | 
return sample_permutation  | 
|
99  | 
sample_permutation = [(1,2), (3,4)]  | 
|
100  | 
from bzrlib.transport import TransportTestProviderAdapter  | 
|
101  | 
adapter = TransportTestProviderAdapter()  | 
|
102  | 
self.assertEqual(sample_permutation,  | 
|
103  | 
adapter.get_transport_test_permutations(MockModule()))  | 
|
104  | 
||
105  | 
def test_adapter_checks_all_modules(self):  | 
|
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
106  | 
        # this checks that the adapter returns as many permurtations as
 | 
107  | 
        # there are in all the registered# transport modules for there
 | 
|
108  | 
        # - we assume if this matches its probably doing the right thing
 | 
|
109  | 
        # especially in combination with the tests for setting the right
 | 
|
110  | 
        # classes below.
 | 
|
| 
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.  | 
111  | 
from bzrlib.transport import (TransportTestProviderAdapter,  | 
112  | 
                                      _get_transport_modules
 | 
|
113  | 
                                      )
 | 
|
114  | 
modules = _get_transport_modules()  | 
|
115  | 
permutation_count = 0  | 
|
116  | 
for module in modules:  | 
|
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
117  | 
try:  | 
118  | 
permutation_count += len(reduce(getattr,  | 
|
119  | 
(module + ".get_test_permutations").split('.')[1:],  | 
|
120  | 
__import__(module))())  | 
|
121  | 
except errors.DependencyNotPresent:  | 
|
122  | 
                pass
 | 
|
| 
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.  | 
123  | 
input_test = TestTransportProviderAdapter(  | 
124  | 
"test_adapter_sets_transport_class")  | 
|
125  | 
adapter = TransportTestProviderAdapter()  | 
|
126  | 
self.assertEqual(permutation_count,  | 
|
127  | 
len(list(iter(adapter.adapt(input_test)))))  | 
|
128  | 
||
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
129  | 
def test_adapter_sets_transport_class(self):  | 
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
130  | 
        # when the adapter adapts a test it needs to 
 | 
131  | 
        # place one of the permutations from the transport
 | 
|
132  | 
        # providers in each test case copy. This checks
 | 
|
133  | 
        # that it does not just use the same one all the time.
 | 
|
134  | 
        # and that the id is set correctly so that debugging is
 | 
|
135  | 
        # easy.
 | 
|
| 
1551.1.1
by Martin Pool
 [merge] branch-formats branch, and reconcile changes  | 
136  | 
        # 
 | 
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)
 | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
140  | 
from bzrlib.transport.local import (LocalTransport,  | 
141  | 
LocalRelpathServer,  | 
|
142  | 
LocalAbspathServer,  | 
|
143  | 
                                            LocalURLServer
 | 
|
144  | 
                                            )
 | 
|
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
145  | 
try:  | 
146  | 
from bzrlib.transport.sftp import (SFTPTransport,  | 
|
147  | 
SFTPAbsoluteServer,  | 
|
148  | 
SFTPHomeDirServer,  | 
|
149  | 
SFTPSiblingAbsoluteServer,  | 
|
150  | 
                                               )
 | 
|
151  | 
except errors.ParamikoNotPresent, e:  | 
|
152  | 
warnings.warn(str(e))  | 
|
153  | 
has_paramiko = False  | 
|
154  | 
else:  | 
|
155  | 
has_paramiko = True  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
156  | 
from bzrlib.transport.http import (HttpTransport,  | 
157  | 
                                           HttpServer
 | 
|
158  | 
                                           )
 | 
|
159  | 
from bzrlib.transport.ftp import FtpTransport  | 
|
| 
1530.1.3
by Robert Collins
 transport implementations now tested consistently.  | 
160  | 
from bzrlib.transport.memory import (MemoryTransport,  | 
161  | 
                                             MemoryServer
 | 
|
162  | 
                                             )
 | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
163  | 
from bzrlib.transport import TransportTestProviderAdapter  | 
164  | 
        # FIXME. What we want is a factory for the things
 | 
|
165  | 
        # needed to test the implementation. I.e. for transport we want:
 | 
|
166  | 
        # the class that connections should get; a local server factory
 | 
|
167  | 
        # so we would want the following permutations:
 | 
|
168  | 
        # LocalTransport relpath-factory
 | 
|
169  | 
        # LocalTransport abspath-factory
 | 
|
170  | 
        # LocalTransport file://-factory
 | 
|
171  | 
        # SFTPTransport homedir-factory
 | 
|
172  | 
        # SFTPTransport abssolute-factory
 | 
|
173  | 
        # HTTPTransport http-factory
 | 
|
174  | 
        # HTTPTransport https-factory
 | 
|
175  | 
        # etc, but we are currently lacking in this, so print out that
 | 
|
176  | 
        # this should be fixed.
 | 
|
177  | 
input_test = TestTransportProviderAdapter(  | 
|
178  | 
"test_adapter_sets_transport_class")  | 
|
179  | 
suite = TransportTestProviderAdapter().adapt(input_test)  | 
|
| 
1551.1.1
by Martin Pool
 [merge] branch-formats branch, and reconcile changes  | 
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
 | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
183  | 
test_iter = iter(suite)  | 
| 
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.  | 
184  | 
http_test = test_iter.next()  | 
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
185  | 
local_relpath_test = test_iter.next()  | 
186  | 
local_abspath_test = test_iter.next()  | 
|
187  | 
local_urlpath_test = test_iter.next()  | 
|
| 
1530.1.19
by Robert Collins
 Make transport test adapter tests reliable.  | 
188  | 
memory_test = test_iter.next()  | 
| 
1534.4.9
by Robert Collins
 Add a readonly decorator for transports.  | 
189  | 
readonly_test = test_iter.next()  | 
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
190  | 
if has_paramiko:  | 
191  | 
sftp_abs_test = test_iter.next()  | 
|
192  | 
sftp_homedir_test = test_iter.next()  | 
|
193  | 
sftp_sibling_abs_test = test_iter.next()  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
194  | 
        # ftp_test = test_iter.next()
 | 
| 
1551.1.1
by Martin Pool
 [merge] branch-formats branch, and reconcile changes  | 
195  | 
        # should now be at the end of the test
 | 
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
196  | 
self.assertRaises(StopIteration, test_iter.next)  | 
197  | 
self.assertEqual(LocalTransport, local_relpath_test.transport_class)  | 
|
198  | 
self.assertEqual(LocalRelpathServer, local_relpath_test.transport_server)  | 
|
199  | 
||
200  | 
self.assertEqual(LocalTransport, local_abspath_test.transport_class)  | 
|
201  | 
self.assertEqual(LocalAbspathServer, local_abspath_test.transport_server)  | 
|
202  | 
||
203  | 
self.assertEqual(LocalTransport, local_urlpath_test.transport_class)  | 
|
204  | 
self.assertEqual(LocalURLServer, local_urlpath_test.transport_server)  | 
|
205  | 
||
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
206  | 
if has_paramiko:  | 
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)  | 
|
| 
1530.1.3
by Robert Collins
 transport implementations now tested consistently.  | 
214  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
215  | 
self.assertEqual(HttpTransport, http_test.transport_class)  | 
216  | 
self.assertEqual(HttpServer, http_test.transport_server)  | 
|
217  | 
        # self.assertEqual(FtpTransport, ftp_test.transport_class)
 | 
|
| 
1530.1.3
by Robert Collins
 transport implementations now tested consistently.  | 
218  | 
|
219  | 
self.assertEqual(MemoryTransport, memory_test.transport_class)  | 
|
220  | 
self.assertEqual(MemoryServer, memory_test.transport_server)  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
221  | 
|
| 
1530.1.3
by Robert Collins
 transport implementations now tested consistently.  | 
222  | 
        # we could test all of them for .id, but two is probably sufficient.
 | 
223  | 
self.assertEqual("bzrlib.tests.test_selftest."  | 
|
224  | 
                         "TestTransportProviderAdapter."
 | 
|
225  | 
"test_adapter_sets_transport_class(MemoryServer)",  | 
|
226  | 
memory_test.id())  | 
|
227  | 
self.assertEqual("bzrlib.tests.test_selftest."  | 
|
228  | 
                         "TestTransportProviderAdapter."
 | 
|
229  | 
"test_adapter_sets_transport_class(LocalRelpathServer)",  | 
|
230  | 
local_relpath_test.id())  | 
|
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
231  | 
|
232  | 
||
233  | 
class TestBranchProviderAdapter(TestCase):  | 
|
234  | 
"""A group of tests that test the branch implementation test adapter."""  | 
|
235  | 
||
236  | 
def test_adapted_tests(self):  | 
|
237  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
238  | 
        # test.
 | 
|
239  | 
from bzrlib.branch import BranchTestProviderAdapter  | 
|
240  | 
input_test = TestBranchProviderAdapter(  | 
|
241  | 
"test_adapted_tests")  | 
|
242  | 
server1 = "a"  | 
|
243  | 
server2 = "b"  | 
|
| 
1534.4.41
by Robert Collins
 Branch now uses BzrDir reasonably sanely.  | 
244  | 
formats = [("c", "C"), ("d", "D")]  | 
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
245  | 
adapter = BranchTestProviderAdapter(server1, server2, formats)  | 
246  | 
suite = adapter.adapt(input_test)  | 
|
247  | 
tests = list(iter(suite))  | 
|
248  | 
self.assertEqual(2, len(tests))  | 
|
| 
1534.4.41
by Robert Collins
 Branch now uses BzrDir reasonably sanely.  | 
249  | 
self.assertEqual(tests[0].branch_format, formats[0][0])  | 
250  | 
self.assertEqual(tests[0].bzrdir_format, formats[0][1])  | 
|
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
251  | 
self.assertEqual(tests[0].transport_server, server1)  | 
252  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
| 
1534.4.41
by Robert Collins
 Branch now uses BzrDir reasonably sanely.  | 
253  | 
self.assertEqual(tests[1].branch_format, formats[1][0])  | 
254  | 
self.assertEqual(tests[1].bzrdir_format, formats[1][1])  | 
|
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
255  | 
self.assertEqual(tests[1].transport_server, server1)  | 
256  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
257  | 
|
258  | 
||
| 
1534.4.39
by Robert Collins
 Basic BzrDir support.  | 
259  | 
class TestBzrDirProviderAdapter(TestCase):  | 
260  | 
"""A group of tests that test the bzr dir implementation test adapter."""  | 
|
261  | 
||
262  | 
def test_adapted_tests(self):  | 
|
263  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
264  | 
        # test.
 | 
|
265  | 
from bzrlib.bzrdir import BzrDirTestProviderAdapter  | 
|
266  | 
input_test = TestBzrDirProviderAdapter(  | 
|
267  | 
"test_adapted_tests")  | 
|
268  | 
server1 = "a"  | 
|
269  | 
server2 = "b"  | 
|
270  | 
formats = ["c", "d"]  | 
|
271  | 
adapter = BzrDirTestProviderAdapter(server1, server2, formats)  | 
|
272  | 
suite = adapter.adapt(input_test)  | 
|
273  | 
tests = list(iter(suite))  | 
|
274  | 
self.assertEqual(2, len(tests))  | 
|
275  | 
self.assertEqual(tests[0].bzrdir_format, formats[0])  | 
|
276  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
277  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
278  | 
self.assertEqual(tests[1].bzrdir_format, formats[1])  | 
|
279  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
280  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
281  | 
||
282  | 
||
| 
1534.4.40
by Robert Collins
 Add RepositoryFormats and allow bzrdir.open or create _repository to be used.  | 
283  | 
class TestRepositoryProviderAdapter(TestCase):  | 
284  | 
"""A group of tests that test the repository implementation test adapter."""  | 
|
285  | 
||
286  | 
def test_adapted_tests(self):  | 
|
287  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
288  | 
        # test.
 | 
|
289  | 
from bzrlib.repository import RepositoryTestProviderAdapter  | 
|
290  | 
input_test = TestRepositoryProviderAdapter(  | 
|
291  | 
"test_adapted_tests")  | 
|
292  | 
server1 = "a"  | 
|
293  | 
server2 = "b"  | 
|
294  | 
formats = [("c", "C"), ("d", "D")]  | 
|
295  | 
adapter = RepositoryTestProviderAdapter(server1, server2, formats)  | 
|
296  | 
suite = adapter.adapt(input_test)  | 
|
297  | 
tests = list(iter(suite))  | 
|
298  | 
self.assertEqual(2, len(tests))  | 
|
299  | 
self.assertEqual(tests[0].bzrdir_format, formats[0][1])  | 
|
300  | 
self.assertEqual(tests[0].repository_format, formats[0][0])  | 
|
301  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
302  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
303  | 
self.assertEqual(tests[1].bzrdir_format, formats[1][1])  | 
|
304  | 
self.assertEqual(tests[1].repository_format, formats[1][0])  | 
|
305  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
306  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
307  | 
||
308  | 
||
| 
1534.1.29
by Robert Collins
 Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.  | 
309  | 
class TestInterRepositoryProviderAdapter(TestCase):  | 
310  | 
"""A group of tests that test the InterRepository test adapter."""  | 
|
311  | 
||
312  | 
def test_adapted_tests(self):  | 
|
313  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
314  | 
        # test.
 | 
|
315  | 
from bzrlib.repository import InterRepositoryTestProviderAdapter  | 
|
316  | 
input_test = TestInterRepositoryProviderAdapter(  | 
|
317  | 
"test_adapted_tests")  | 
|
318  | 
server1 = "a"  | 
|
319  | 
server2 = "b"  | 
|
320  | 
formats = [(str, "C1", "C2"), (str, "D1", "D2")]  | 
|
321  | 
adapter = InterRepositoryTestProviderAdapter(server1, server2, formats)  | 
|
322  | 
suite = adapter.adapt(input_test)  | 
|
323  | 
tests = list(iter(suite))  | 
|
324  | 
self.assertEqual(2, len(tests))  | 
|
325  | 
self.assertEqual(tests[0].interrepo_class, formats[0][0])  | 
|
326  | 
self.assertEqual(tests[0].repository_format, formats[0][1])  | 
|
327  | 
self.assertEqual(tests[0].repository_format_to, formats[0][2])  | 
|
328  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
329  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
330  | 
self.assertEqual(tests[0].interrepo_class, formats[1][0])  | 
|
331  | 
self.assertEqual(tests[1].repository_format, formats[1][1])  | 
|
332  | 
self.assertEqual(tests[1].repository_format_to, formats[1][2])  | 
|
333  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
334  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
335  | 
||
336  | 
||
| 
1534.4.46
by Robert Collins
 Nearly complete .bzr/checkout splitout.  | 
337  | 
class TestWorkingTreeProviderAdapter(TestCase):  | 
338  | 
"""A group of tests that test the workingtree implementation test adapter."""  | 
|
339  | 
||
340  | 
def test_adapted_tests(self):  | 
|
341  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
342  | 
        # test.
 | 
|
343  | 
from bzrlib.workingtree import WorkingTreeTestProviderAdapter  | 
|
344  | 
input_test = TestWorkingTreeProviderAdapter(  | 
|
345  | 
"test_adapted_tests")  | 
|
346  | 
server1 = "a"  | 
|
347  | 
server2 = "b"  | 
|
348  | 
formats = [("c", "C"), ("d", "D")]  | 
|
349  | 
adapter = WorkingTreeTestProviderAdapter(server1, server2, formats)  | 
|
350  | 
suite = adapter.adapt(input_test)  | 
|
351  | 
tests = list(iter(suite))  | 
|
352  | 
self.assertEqual(2, len(tests))  | 
|
353  | 
self.assertEqual(tests[0].workingtree_format, formats[0][0])  | 
|
354  | 
self.assertEqual(tests[0].bzrdir_format, formats[0][1])  | 
|
355  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
356  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
357  | 
self.assertEqual(tests[1].workingtree_format, formats[1][0])  | 
|
358  | 
self.assertEqual(tests[1].bzrdir_format, formats[1][1])  | 
|
359  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
360  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
361  | 
||
362  | 
||
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
363  | 
class TestTestCaseWithTransport(TestCaseWithTransport):  | 
364  | 
"""Tests for the convenience functions TestCaseWithTransport introduces."""  | 
|
365  | 
||
366  | 
def test_get_readonly_url_none(self):  | 
|
367  | 
from bzrlib.transport import get_transport  | 
|
368  | 
from bzrlib.transport.memory import MemoryServer  | 
|
369  | 
from bzrlib.transport.readonly import ReadonlyTransportDecorator  | 
|
370  | 
self.transport_server = MemoryServer  | 
|
371  | 
self.transport_readonly_server = None  | 
|
372  | 
        # calling get_readonly_transport() constructs a decorator on the url
 | 
|
373  | 
        # for the server
 | 
|
374  | 
url = self.get_readonly_url()  | 
|
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
375  | 
url2 = self.get_readonly_url('foo/bar')  | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
376  | 
t = get_transport(url)  | 
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
377  | 
t2 = get_transport(url2)  | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
378  | 
self.failUnless(isinstance(t, ReadonlyTransportDecorator))  | 
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
379  | 
self.failUnless(isinstance(t2, ReadonlyTransportDecorator))  | 
380  | 
self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))  | 
|
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
381  | 
|
382  | 
def test_get_readonly_url_http(self):  | 
|
383  | 
from bzrlib.transport import get_transport  | 
|
384  | 
from bzrlib.transport.local import LocalRelpathServer  | 
|
385  | 
from bzrlib.transport.http import HttpServer, HttpTransport  | 
|
386  | 
self.transport_server = LocalRelpathServer  | 
|
387  | 
self.transport_readonly_server = HttpServer  | 
|
388  | 
        # calling get_readonly_transport() gives us a HTTP server instance.
 | 
|
389  | 
url = self.get_readonly_url()  | 
|
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
390  | 
url2 = self.get_readonly_url('foo/bar')  | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
391  | 
t = get_transport(url)  | 
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
392  | 
t2 = get_transport(url2)  | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
393  | 
self.failUnless(isinstance(t, HttpTransport))  | 
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
394  | 
self.failUnless(isinstance(t2, HttpTransport))  | 
395  | 
self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))  | 
|
| 
1534.4.31
by Robert Collins
 cleanedup test_outside_wt  | 
396  | 
|
397  | 
||
398  | 
class TestChrootedTest(ChrootedTestCase):  | 
|
399  | 
||
400  | 
def test_root_is_root(self):  | 
|
401  | 
from bzrlib.transport import get_transport  | 
|
402  | 
t = get_transport(self.get_readonly_url())  | 
|
403  | 
url = t.base  | 
|
404  | 
self.assertEqual(url, t.clone('..').base)  |