bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
|
1563.2.12
by Robert Collins
Checkpointing: created InterObject to factor out common inter object worker code, added InterVersionedFile and tests to allow making join work between any versionedfile. |
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
18 |
||
19 |
"""InterVersioned implementation tests for bzr.
|
|
20 |
||
21 |
These test the conformance of all the interversionedfile variations to the
|
|
22 |
expected API including generally applicable corner cases.
|
|
23 |
Specific tests for individual cases are in the tests/test_versionedfile.py file
|
|
24 |
rather than in tests/interversionedfile_implementations/*.py.
|
|
25 |
"""
|
|
26 |
||
27 |
from bzrlib.tests import ( |
|
28 |
adapt_modules, |
|
29 |
default_transport, |
|
30 |
TestLoader, |
|
|
2553.2.8
by Robert Collins
And overhaul InterVersionedFileTestProviderAdapter too. |
31 |
TestScenarioApplier, |
|
1563.2.12
by Robert Collins
Checkpointing: created InterObject to factor out common inter object worker code, added InterVersionedFile and tests to allow making join work between any versionedfile. |
32 |
TestSuite, |
33 |
)
|
|
34 |
||
35 |
||
|
2553.2.8
by Robert Collins
And overhaul InterVersionedFileTestProviderAdapter too. |
36 |
class InterVersionedFileTestProviderAdapter(TestScenarioApplier): |
37 |
"""A tool to generate a suite testing multiple inter versioned-file classes. |
|
38 |
||
39 |
This is done by copying the test once for each InterVersionedFile provider
|
|
40 |
and injecting the transport_server, transport_readonly_server,
|
|
41 |
versionedfile_factory and versionedfile_factory_to classes into each copy.
|
|
42 |
Each copy is also given a new id() to make it easy to identify.
|
|
43 |
"""
|
|
44 |
||
45 |
def __init__(self, transport_server, transport_readonly_server, formats): |
|
46 |
self._transport_server = transport_server |
|
47 |
self._transport_readonly_server = transport_readonly_server |
|
48 |
self.scenarios = self.formats_to_scenarios(formats) |
|
49 |
||
50 |
def formats_to_scenarios(self, formats): |
|
51 |
"""Transform the input formats to a list of scenarios. |
|
52 |
||
53 |
:param formats: A list of tuples:
|
|
54 |
(interversionedfile_class, versionedfile_factory,
|
|
55 |
versionedfile_factory_to).
|
|
56 |
"""
|
|
57 |
result = [] |
|
58 |
for (interversionedfile_class, |
|
59 |
versionedfile_factory, |
|
60 |
versionedfile_factory_to) in formats: |
|
61 |
scenario = (interversionedfile_class.__name__, { |
|
62 |
"transport_server":self._transport_server, |
|
63 |
"transport_readonly_server":self._transport_readonly_server, |
|
64 |
"interversionedfile_class":interversionedfile_class, |
|
65 |
"versionedfile_factory":versionedfile_factory, |
|
66 |
"versionedfile_factory_to":versionedfile_factory_to, |
|
67 |
})
|
|
68 |
result.append(scenario) |
|
69 |
return result |
|
70 |
||
71 |
@staticmethod
|
|
72 |
def default_test_list(): |
|
73 |
"""Generate the default list of interversionedfile permutations to test.""" |
|
74 |
from bzrlib.versionedfile import InterVersionedFile |
|
75 |
from bzrlib.weave import WeaveFile |
|
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
76 |
from bzrlib.knit import make_file_knit |
|
2553.2.8
by Robert Collins
And overhaul InterVersionedFileTestProviderAdapter too. |
77 |
result = [] |
78 |
# test the fallback InterVersionedFile from annotated knits to weave
|
|
79 |
result.append((InterVersionedFile, |
|
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
80 |
make_file_knit, |
|
2553.2.8
by Robert Collins
And overhaul InterVersionedFileTestProviderAdapter too. |
81 |
WeaveFile)) |
82 |
for optimiser in InterVersionedFile._optimisers: |
|
83 |
result.append((optimiser, |
|
84 |
optimiser._matching_file_from_factory, |
|
85 |
optimiser._matching_file_to_factory |
|
86 |
))
|
|
87 |
# if there are specific combinations we want to use, we can add them
|
|
88 |
# here.
|
|
89 |
return result |
|
90 |
||
91 |
||
|
1563.2.12
by Robert Collins
Checkpointing: created InterObject to factor out common inter object worker code, added InterVersionedFile and tests to allow making join work between any versionedfile. |
92 |
def test_suite(): |
93 |
result = TestSuite() |
|
94 |
test_interversionedfile_implementations = [ |
|
95 |
'bzrlib.tests.interversionedfile_implementations.test_join', |
|
96 |
]
|
|
97 |
adapter = InterVersionedFileTestProviderAdapter( |
|
98 |
default_transport, |
|
99 |
# None here will cause a readonly decorator to be created
|
|
100 |
# by the TestCaseWithTransport.get_readonly_transport method.
|
|
101 |
None, |
|
102 |
InterVersionedFileTestProviderAdapter.default_test_list() |
|
103 |
)
|
|
104 |
loader = TestLoader() |
|
105 |
adapt_modules(test_interversionedfile_implementations, adapter, loader, result) |
|
106 |
return result |