/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3221.10.1 by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
1
# Copyright (C) 2008 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 as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
18
"""Repository implementation tests for external reference repositories.
19
3474.2.1 by Martin Pool
Merge and cleanup pre-external-reference-repository tests
20
These tests check the conformance of repositories which refer to other
21
repositories for some data, and are run for each repository format supporting
22
this.
3221.10.1 by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
23
"""
24
25
from bzrlib import (
26
    repository,
27
    remote,
28
    )
29
from bzrlib.bzrdir import BzrDir
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
30
from bzrlib.tests import multiply_tests
3689.1.1 by John Arbash Meinel
Rename repository_implementations tests into per_repository tests
31
from bzrlib.tests.per_repository import (
3221.10.1 by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
32
    all_repository_format_scenarios,
33
    TestCaseWithRepository,
34
    )
35
36
37
class TestCaseWithExternalReferenceRepository(TestCaseWithRepository):
38
39
    def make_referring(self, relpath, target_path):
40
        """Get a new repository that refers to a_repository.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
41
3221.10.1 by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
42
        :param relpath: The path to create the repository at.
43
        :param a_repository: A repository to refer to.
44
        """
45
        repo = self.make_repository(relpath)
46
        repo.add_fallback_repository(self.readonly_repository(target_path))
47
        return repo
48
49
    def readonly_repository(self, relpath):
50
        return BzrDir.open_from_transport(
51
            self.get_readonly_transport(relpath)).open_repository()
52
53
54
class TestCorrectFormat(TestCaseWithExternalReferenceRepository):
55
56
    def test_repository_format(self):
57
        # make sure the repository on tree.branch is of the desired format,
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
58
        # because developers use this api to setup the tree, branch and
3221.10.1 by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
59
        # repository for their tests: having it not give the right repository
60
        # type would invalidate the tests.
61
        self.make_branch_and_tree('repo')
62
        repo = self.make_referring('referring', 'repo')
63
        self.assertIsInstance(repo._format,
64
            self.repository_format.__class__)
65
66
3474.2.1 by Martin Pool
Merge and cleanup pre-external-reference-repository tests
67
def external_reference_test_scenarios():
68
    """Generate test scenarios for repositories supporting external references.
69
    """
70
    result = []
71
    for test_name, scenario_info in all_repository_format_scenarios():
3221.10.1 by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
72
        # For remote repositories, we need at least one external reference
73
        # capable format to test it: defer this until landing such a format.
74
        # if isinstance(format, remote.RemoteRepositoryFormat):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
75
        #     scenario[1]['bzrdir_format'].repository_format =
3474.2.1 by Martin Pool
Merge and cleanup pre-external-reference-repository tests
76
        if scenario_info['repository_format'].supports_external_lookups:
77
            result.append((test_name, scenario_info))
78
    return result
79
80
81
def load_tests(standard_tests, module, loader):
82
    module_list = [
83
        'bzrlib.tests.per_repository_reference.test_add_inventory',
84
        'bzrlib.tests.per_repository_reference.test_add_revision',
85
        'bzrlib.tests.per_repository_reference.test_add_signature_text',
86
        'bzrlib.tests.per_repository_reference.test_all_revision_ids',
87
        'bzrlib.tests.per_repository_reference.test_break_lock',
88
        'bzrlib.tests.per_repository_reference.test_check',
4103.2.3 by Andrew Bennetts
Other tests for good luck.
89
        'bzrlib.tests.per_repository_reference.test_default_stacking',
3221.10.1 by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests.
90
        ]
3689.1.4 by John Arbash Meinel
Doc strings that reference repository_implementations
91
    # Parameterize per_repository_reference test modules by format.
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
92
    standard_tests.addTests(loader.loadTestsFromModuleNames(module_list))
93
    return multiply_tests(standard_tests, external_reference_test_scenarios(),
94
        loader.suiteClass())