bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4537.3.1
by John Arbash Meinel
Start working on tests that get_record_stream gives reasonable results w/ stacking. |
1 |
# Copyright (C) 2008, 2009 Canonical Ltd
|
|
3221.10.1
by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests. |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
3221.10.1
by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests. |
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 |
)
|
|
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
29 |
from bzrlib.branch import BzrBranchFormat7 |
|
3221.10.1
by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests. |
30 |
from bzrlib.bzrdir import BzrDir |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
31 |
from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack6 |
|
4084.5.1
by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters. |
32 |
from bzrlib.tests import multiply_tests |
|
3689.1.1
by John Arbash Meinel
Rename repository_implementations tests into per_repository tests |
33 |
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. |
34 |
all_repository_format_scenarios, |
35 |
TestCaseWithRepository, |
|
36 |
)
|
|
37 |
||
38 |
||
39 |
class TestCaseWithExternalReferenceRepository(TestCaseWithRepository): |
|
40 |
||
41 |
def make_referring(self, relpath, target_path): |
|
42 |
"""Get a new repository that refers to a_repository. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
43 |
|
|
3221.10.1
by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests. |
44 |
:param relpath: The path to create the repository at.
|
45 |
:param a_repository: A repository to refer to.
|
|
46 |
"""
|
|
47 |
repo = self.make_repository(relpath) |
|
48 |
repo.add_fallback_repository(self.readonly_repository(target_path)) |
|
49 |
return repo |
|
50 |
||
51 |
def readonly_repository(self, relpath): |
|
52 |
return BzrDir.open_from_transport( |
|
53 |
self.get_readonly_transport(relpath)).open_repository() |
|
54 |
||
55 |
||
56 |
class TestCorrectFormat(TestCaseWithExternalReferenceRepository): |
|
57 |
||
58 |
def test_repository_format(self): |
|
59 |
# 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 |
60 |
# 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. |
61 |
# repository for their tests: having it not give the right repository
|
62 |
# type would invalidate the tests.
|
|
63 |
self.make_branch_and_tree('repo') |
|
64 |
repo = self.make_referring('referring', 'repo') |
|
65 |
self.assertIsInstance(repo._format, |
|
66 |
self.repository_format.__class__) |
|
67 |
||
68 |
||
|
3474.2.1
by Martin Pool
Merge and cleanup pre-external-reference-repository tests |
69 |
def external_reference_test_scenarios(): |
70 |
"""Generate test scenarios for repositories supporting external references. |
|
71 |
"""
|
|
72 |
result = [] |
|
73 |
for test_name, scenario_info in all_repository_format_scenarios(): |
|
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
74 |
format = scenario_info['repository_format'] |
75 |
if isinstance(format, remote.RemoteRepositoryFormat): |
|
76 |
# This is a RemoteRepositoryFormat scenario. Force the scenario to
|
|
77 |
# use real branch and repository formats that support references.
|
|
78 |
scenario_info = dict(scenario_info) |
|
79 |
format = remote.RemoteRepositoryFormat() |
|
80 |
format._custom_format = RepositoryFormatKnitPack6() |
|
81 |
scenario_info['repository_format'] = format |
|
82 |
bzrdir_format = remote.RemoteBzrDirFormat() |
|
83 |
bzrdir_format.repository_format = format |
|
84 |
bzrdir_format.set_branch_format(BzrBranchFormat7()) |
|
85 |
scenario_info['bzrdir_format'] = bzrdir_format |
|
86 |
if format.supports_external_lookups: |
|
|
3474.2.1
by Martin Pool
Merge and cleanup pre-external-reference-repository tests |
87 |
result.append((test_name, scenario_info)) |
88 |
return result |
|
89 |
||
90 |
||
91 |
def load_tests(standard_tests, module, loader): |
|
92 |
module_list = [ |
|
93 |
'bzrlib.tests.per_repository_reference.test_add_inventory', |
|
94 |
'bzrlib.tests.per_repository_reference.test_add_revision', |
|
95 |
'bzrlib.tests.per_repository_reference.test_add_signature_text', |
|
96 |
'bzrlib.tests.per_repository_reference.test_all_revision_ids', |
|
97 |
'bzrlib.tests.per_repository_reference.test_break_lock', |
|
98 |
'bzrlib.tests.per_repository_reference.test_check', |
|
|
4103.2.3
by Andrew Bennetts
Other tests for good luck. |
99 |
'bzrlib.tests.per_repository_reference.test_default_stacking', |
|
4343.3.10
by John Arbash Meinel
Add a per_repository_reference test with real stacked repos. |
100 |
'bzrlib.tests.per_repository_reference.test_fetch', |
|
4537.3.1
by John Arbash Meinel
Start working on tests that get_record_stream gives reasonable results w/ stacking. |
101 |
'bzrlib.tests.per_repository_reference.test_get_record_stream', |
|
4419.2.9
by Andrew Bennetts
Add per_repository_reference test for get_rev_id_for_revno, fix the bugs it revealed. |
102 |
'bzrlib.tests.per_repository_reference.test_get_rev_id_for_revno', |
|
4379.2.2
by John Arbash Meinel
Change the Repository.add_fallback_repository() contract slightly. |
103 |
'bzrlib.tests.per_repository_reference.test_initialize', |
|
4379.2.1
by John Arbash Meinel
Change the fallback repository code to only lock/unlock on transition. |
104 |
'bzrlib.tests.per_repository_reference.test_unlock', |
|
3221.10.1
by Robert Collins
Add add_inventory external reference interface tests and tweak broken test support function adapt_tests. |
105 |
]
|
|
3689.1.4
by John Arbash Meinel
Doc strings that reference repository_implementations |
106 |
# 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. |
107 |
standard_tests.addTests(loader.loadTestsFromModuleNames(module_list)) |
108 |
return multiply_tests(standard_tests, external_reference_test_scenarios(), |
|
109 |
loader.suiteClass()) |