/brz/remove-bazaar

To get this branch, use:
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
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
2
# Authors: Robert Collins <robert.collins@canonical.com>
3
# -*- coding: utf-8 -*-
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
4
#
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
9
#
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
14
#
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
18
19
20
"""InterRepository implementation tests for bzr.
21
22
These test the conformance of all the interrepository variations to the
23
expected API including generally applicable corner cases.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
24
Specific tests for individual formats are in the tests/test_repository.py file
4523.1.3 by Martin Pool
Rename to per_interrepository
25
rather than in tests/per_interrepository/*.py.
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
26
"""
27
3380.1.4 by Aaron Bentley
Split interrepository fetch tests into their own file
28
29
from bzrlib.errors import (
30
    FileExists,
31
    UninitializableFormat,
32
    )
33
2241.1.4 by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo.
34
from bzrlib.repository import (
4257.3.8 by Andrew Bennetts
Fix TestCase.make_branch_builder to make a branch in the specified format. Also add an interrepo test scenario for KnitPack1 -> KnitPack6RichRoot, which fails.
35
    InterDifferingSerializer,
36
    InterKnitRepo,
37
    InterRepository,
38
    )
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
39
from bzrlib.tests import (
40
                          default_transport,
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
41
                          multiply_tests,
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
42
                          )
4523.1.2 by Martin Pool
Rename bzrdir_implementations to per_bzrdir
43
from bzrlib.tests.per_bzrdir.test_bzrdir import TestCaseWithBzrDir
3380.1.4 by Aaron Bentley
Split interrepository fetch tests into their own file
44
from bzrlib.transport import get_transport
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
45
46
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
47
def make_scenarios(transport_server, transport_readonly_server, formats):
48
    """Transform the input formats to a list of scenarios.
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
49
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
50
    :param formats: A list of tuples:
51
        (interrepo_class, repository_format, repository_format_to).
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
52
    """
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
53
    result = []
54
    for interrepo_class, repository_format, repository_format_to in formats:
55
        id = '%s,%s,%s' % (interrepo_class.__name__,
56
                            repository_format.__class__.__name__,
57
                            repository_format_to.__class__.__name__)
58
        scenario = (id,
59
            {"transport_server": transport_server,
60
             "transport_readonly_server": transport_readonly_server,
61
             "repository_format": repository_format,
62
             "interrepo_class": interrepo_class,
63
             "repository_format_to": repository_format_to,
64
             })
65
        result.append(scenario)
66
    return result
67
68
69
def default_test_list():
70
    """Generate the default list of interrepo permutations to test."""
4597.1.3 by John Arbash Meinel
Add a conversion to 2a format to make sure things get tested, see that it is now failing the inventories test.
71
    from bzrlib.repofmt import (
72
        groupcompress_repo,
73
        knitrepo,
74
        pack_repo,
75
        weaverepo,
76
        )
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
77
    result = []
78
    # test the default InterRepository between format 6 and the current
79
    # default format.
80
    # XXX: robertc 20060220 reinstate this when there are two supported
81
    # formats which do not have an optimal code path between them.
82
    #result.append((InterRepository,
83
    #               RepositoryFormat6(),
84
    #               RepositoryFormatKnit1()))
85
    for optimiser_class in InterRepository._optimisers:
86
        format_to_test = optimiser_class._get_repo_format_to_test()
87
        if format_to_test is not None:
88
            result.append((optimiser_class,
89
                           format_to_test, format_to_test))
90
    # if there are specific combinations we want to use, we can add them
91
    # here. We want to test rich root upgrading.
92
    result.append((InterRepository,
93
                   weaverepo.RepositoryFormat5(),
94
                   knitrepo.RepositoryFormatKnit3()))
95
    result.append((InterRepository,
96
                   knitrepo.RepositoryFormatKnit1(),
97
                   knitrepo.RepositoryFormatKnit3()))
98
    result.append((InterRepository,
99
                   knitrepo.RepositoryFormatKnit1(),
100
                   knitrepo.RepositoryFormatKnit3()))
101
    result.append((InterKnitRepo,
102
                   knitrepo.RepositoryFormatKnit1(),
103
                   pack_repo.RepositoryFormatKnitPack1()))
104
    result.append((InterKnitRepo,
105
                   pack_repo.RepositoryFormatKnitPack1(),
106
                   knitrepo.RepositoryFormatKnit1()))
107
    result.append((InterKnitRepo,
108
                   knitrepo.RepositoryFormatKnit3(),
109
                   pack_repo.RepositoryFormatKnitPack3()))
110
    result.append((InterKnitRepo,
111
                   pack_repo.RepositoryFormatKnitPack3(),
112
                   knitrepo.RepositoryFormatKnit3()))
113
    result.append((InterKnitRepo,
114
                   pack_repo.RepositoryFormatKnitPack3(),
115
                   pack_repo.RepositoryFormatKnitPack4()))
4257.3.8 by Andrew Bennetts
Fix TestCase.make_branch_builder to make a branch in the specified format. Also add an interrepo test scenario for KnitPack1 -> KnitPack6RichRoot, which fails.
116
    result.append((InterDifferingSerializer,
117
                   pack_repo.RepositoryFormatKnitPack1(),
118
                   pack_repo.RepositoryFormatKnitPack6RichRoot()))
4597.1.3 by John Arbash Meinel
Add a conversion to 2a format to make sure things get tested, see that it is now failing the inventories test.
119
    result.append((InterDifferingSerializer,
120
                   pack_repo.RepositoryFormatKnitPack6RichRoot(),
121
                   groupcompress_repo.RepositoryFormat2a()))
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
122
    return result
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
123
124
3380.1.4 by Aaron Bentley
Split interrepository fetch tests into their own file
125
class TestCaseWithInterRepository(TestCaseWithBzrDir):
126
127
    def setUp(self):
128
        super(TestCaseWithInterRepository, self).setUp()
129
130
    def make_branch(self, relpath, format=None):
131
        repo = self.make_repository(relpath, format=format)
132
        return repo.bzrdir.create_branch()
133
134
    def make_bzrdir(self, relpath, format=None):
135
        try:
136
            url = self.get_url(relpath)
137
            segments = url.split('/')
138
            if segments and segments[-1] not in ('', '.'):
139
                parent = '/'.join(segments[:-1])
140
                t = get_transport(parent)
141
                try:
142
                    t.mkdir(segments[-1])
143
                except FileExists:
144
                    pass
145
            if format is None:
146
                format = self.repository_format._matchingbzrdir
147
            return format.initialize(url)
148
        except UninitializableFormat:
149
            raise TestSkipped("Format %s is not initializable." % format)
150
151
    def make_repository(self, relpath, format=None):
152
        made_control = self.make_bzrdir(relpath, format=format)
153
        return self.repository_format.initialize(made_control)
154
155
    def make_to_repository(self, relpath):
156
        made_control = self.make_bzrdir(relpath,
157
            self.repository_format_to._matchingbzrdir)
158
        return self.repository_format_to.initialize(made_control)
159
160
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
161
def load_tests(standard_tests, module, loader):
162
    submod_tests = loader.loadTestsFromModuleNames([
4523.1.3 by Martin Pool
Rename to per_interrepository
163
        'bzrlib.tests.per_interrepository.test_fetch',
164
        'bzrlib.tests.per_interrepository.test_interrepository',
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
165
        ])
166
    scenarios = make_scenarios(
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
167
        default_transport,
168
        # None here will cause a readonly decorator to be created
169
        # by the TestCaseWithTransport.get_readonly_transport method.
170
        None,
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
171
        default_test_list()
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
172
        )
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
173
    return multiply_tests(submod_tests, scenarios, standard_tests)