/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
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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.
24
Specific tests for individual formats are in the tests/test_repository.py file 
25
rather than in tests/interrepository_implementations/*.py.
26
"""
27
2241.1.4 by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo.
28
from bzrlib.repository import (
2998.2.2 by John Arbash Meinel
implement a faster path for copying from packs back to knits.
29
                               InterKnitRepo,
30
                               InterKnit1and2,
31
                               InterModel1and2,
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
32
                               InterRepository,
33
                               )
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
34
from bzrlib.tests import (
35
                          adapt_modules,
36
                          default_transport,
37
                          TestLoader,
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
38
                          TestScenarioApplier,
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
39
                          TestSuite,
40
                          )
41
42
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
43
class InterRepositoryTestProviderAdapter(TestScenarioApplier):
44
    """A tool to generate a suite testing multiple inter repository formats.
45
46
    This is done by copying the test once for each interrepo provider and injecting
47
    the transport_server, transport_readonly_server, repository_format and 
48
    repository_to_format classes into each copy.
49
    Each copy is also given a new id() to make it easy to identify.
50
    """
51
52
    def __init__(self, transport_server, transport_readonly_server, formats):
53
        TestScenarioApplier.__init__(self)
54
        self._transport_server = transport_server
55
        self._transport_readonly_server = transport_readonly_server
56
        self.scenarios = self.formats_to_scenarios(formats)
57
    
58
    def formats_to_scenarios(self, formats):
59
        """Transform the input formats to a list of scenarios.
60
61
        :param formats: A list of tuples:
62
            (interrepo_class, repository_format, repository_format_to).
63
        """
64
        result = []
65
        for interrepo_class, repository_format, repository_format_to in formats:
66
            scenario = (interrepo_class.__name__,
67
                {"transport_server":self._transport_server,
68
                 "transport_readonly_server":self._transport_readonly_server,
69
                 "repository_format":repository_format,
70
                 "interrepo_class":interrepo_class,
71
                 "repository_format_to":repository_format_to,
72
                 })
73
            result.append(scenario)
74
        return result
75
    
76
    @staticmethod
77
    def default_test_list():
78
        """Generate the default list of interrepo permutations to test."""
2998.2.2 by John Arbash Meinel
implement a faster path for copying from packs back to knits.
79
        from bzrlib.repofmt import knitrepo, pack_repo, weaverepo
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
80
        result = []
81
        # test the default InterRepository between format 6 and the current 
82
        # default format.
83
        # XXX: robertc 20060220 reinstate this when there are two supported
84
        # formats which do not have an optimal code path between them.
85
        #result.append((InterRepository,
86
        #               RepositoryFormat6(),
87
        #               RepositoryFormatKnit1()))
88
        for optimiser_class in InterRepository._optimisers:
89
            format_to_test = optimiser_class._get_repo_format_to_test()
90
            if format_to_test is not None:
91
                result.append((optimiser_class,
92
                               format_to_test, format_to_test))
93
        # if there are specific combinations we want to use, we can add them 
94
        # here.
95
        result.append((InterModel1and2,
96
                       weaverepo.RepositoryFormat5(),
97
                       knitrepo.RepositoryFormatKnit3()))
2949.1.2 by Robert Collins
* Fetch with pack repositories will no longer read the entire history graph.
98
        result.append((InterModel1and2,
99
                       knitrepo.RepositoryFormatKnit1(),
100
                       knitrepo.RepositoryFormatKnit3()))
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
101
        result.append((InterKnit1and2,
102
                       knitrepo.RepositoryFormatKnit1(),
103
                       knitrepo.RepositoryFormatKnit3()))
2998.2.2 by John Arbash Meinel
implement a faster path for copying from packs back to knits.
104
        result.append((InterKnitRepo,
105
                       knitrepo.RepositoryFormatKnit1(),
106
                       pack_repo.RepositoryFormatKnitPack1()))
107
        result.append((InterKnitRepo,
108
                       pack_repo.RepositoryFormatKnitPack1(),
109
                       knitrepo.RepositoryFormatKnit1()))
110
        result.append((InterKnitRepo,
111
                       knitrepo.RepositoryFormatKnit3(),
112
                       pack_repo.RepositoryFormatKnitPack3()))
113
        result.append((InterKnitRepo,
114
                       pack_repo.RepositoryFormatKnitPack3(),
115
                       knitrepo.RepositoryFormatKnit3()))
2553.2.4 by Robert Collins
Treat InterRepositoryTestProviderAdapter like RepositoryTestProviderAdapter
116
        return result
117
118
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
119
def test_suite():
120
    result = TestSuite()
121
    test_interrepository_implementations = [
122
        'bzrlib.tests.interrepository_implementations.test_interrepository',
123
        ]
124
    adapter = InterRepositoryTestProviderAdapter(
125
        default_transport,
126
        # None here will cause a readonly decorator to be created
127
        # by the TestCaseWithTransport.get_readonly_transport method.
128
        None,
129
        InterRepositoryTestProviderAdapter.default_test_list()
130
        )
131
    loader = TestLoader()
132
    adapt_modules(test_interrepository_implementations, adapter, loader, result)
133
    return result