1
# Copyright (C) 2008 Canonical Ltd
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.
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.
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
18
"""Repository implementation tests for external reference repositories.
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
29
from bzrlib.bzrdir import BzrDir
30
from bzrlib.tests import (
36
from bzrlib.tests.repository_implementations import (
37
all_repository_format_scenarios,
38
TestCaseWithRepository,
42
class TestCaseWithExternalReferenceRepository(TestCaseWithRepository):
44
def make_referring(self, relpath, target_path):
45
"""Get a new repository that refers to a_repository.
47
:param relpath: The path to create the repository at.
48
:param a_repository: A repository to refer to.
50
repo = self.make_repository(relpath)
51
repo.add_fallback_repository(self.readonly_repository(target_path))
54
def readonly_repository(self, relpath):
55
return BzrDir.open_from_transport(
56
self.get_readonly_transport(relpath)).open_repository()
59
class TestCorrectFormat(TestCaseWithExternalReferenceRepository):
61
def test_repository_format(self):
62
# make sure the repository on tree.branch is of the desired format,
63
# because developers use this api to setup the tree, branch and
64
# repository for their tests: having it not give the right repository
65
# type would invalidate the tests.
66
self.make_branch_and_tree('repo')
67
repo = self.make_referring('referring', 'repo')
68
self.assertIsInstance(repo._format,
69
self.repository_format.__class__)
72
def external_reference_test_scenarios():
73
"""Generate test scenarios for repositories supporting external references.
76
for test_name, scenario_info in all_repository_format_scenarios():
77
# For remote repositories, we need at least one external reference
78
# capable format to test it: defer this until landing such a format.
79
# if isinstance(format, remote.RemoteRepositoryFormat):
80
# scenario[1]['bzrdir_format'].repository_format =
81
if scenario_info['repository_format'].supports_external_lookups:
82
result.append((test_name, scenario_info))
86
def load_tests(standard_tests, module, loader):
87
adapter = TestScenarioApplier()
88
adapter.scenarios = external_reference_test_scenarios()
91
'bzrlib.tests.per_repository_reference.test_add_inventory',
92
'bzrlib.tests.per_repository_reference.test_add_revision',
93
'bzrlib.tests.per_repository_reference.test_add_signature_text',
94
'bzrlib.tests.per_repository_reference.test_all_revision_ids',
95
'bzrlib.tests.per_repository_reference.test_break_lock',
96
'bzrlib.tests.per_repository_reference.test_check',
98
# Parameterize repository_implementations test modules by format.
100
adapt_tests(standard_tests, adapter, result)
101
adapt_modules(module_list, adapter, loader, result)