/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
1
# Copyright (C) 2008, 2009 Canonical Ltd
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
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
3735.36.3 by John Arbash Meinel
Add the new address for FSF to the new files.
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
16
17
18
"""Repository implementation tests for CHK support.
19
20
These tests check the conformance of the chk index some repositories support.
21
All repository formats are tested - those that do not suppport chk indices
22
have the test_unsupported tests run; the others have the test_supported tests
23
run.
24
"""
25
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
26
from breezy import (
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
27
    repository,
6670.4.14 by Jelmer Vernooij
Move remote to breezy.bzr.
28
    )
29
from breezy.bzr import (
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
30
    remote,
31
    )
6670.4.5 by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr.
32
from breezy.bzr.knitpack_repo import (
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
33
    RepositoryFormatKnitPack5,
4241.6.8 by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil)
34
    )
6670.4.5 by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr.
35
from breezy.bzr.groupcompress_repo import (
5546.1.1 by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2.
36
    RepositoryFormat2a,
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
37
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
38
from breezy.tests import (
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
39
    multiply_tests,
40
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
41
from breezy.tests.per_repository import (
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
42
    all_repository_format_scenarios,
43
    TestCaseWithRepository,
44
    )
45
46
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
47
class TestCaseWithRepositoryCHK(TestCaseWithRepository):
48
4634.35.10 by Andrew Bennetts
Move tests to per_repository_chk.
49
    def make_repository(self, path, format=None):
50
        TestCaseWithRepository.make_repository(self, path, format=format)
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
51
        return repository.Repository.open(self.get_transport(path).base)
52
53
6625.1.5 by Martin
Drop custom load_tests implementation and use unittest signature
54
def load_tests(loader, standard_tests, pattern):
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
55
    supported_scenarios = []
56
    unsupported_scenarios = []
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
57
    for test_name, scenario_info in all_repository_format_scenarios():
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
58
        format = scenario_info['repository_format']
59
        # For remote repositories, we test both with, and without a backing chk
60
        # capable format: change the format we use to create the repo to direct
61
        # formats, and then the overridden make_repository in
3735.2.7 by Robert Collins
Explanations.
62
        # TestCaseWithRepositoryCHK will give a re-opened RemoteRepository
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
63
        # with the chosen backing format.
64
        if isinstance(format, remote.RemoteRepositoryFormat):
65
            with_support = dict(scenario_info)
5546.1.1 by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2.
66
            with_support['repository_format'] = RepositoryFormat2a()
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
67
            supported_scenarios.append((test_name + "(Supported)", with_support))
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
68
            no_support = dict(scenario_info)
69
            no_support['repository_format'] = RepositoryFormatKnitPack5()
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
70
            unsupported_scenarios.append((test_name + "(Not Supported)", no_support))
3735.2.4 by Robert Collins
Test RemoteRepository with and with-out chk index backing formats.
71
        elif format.supports_chks:
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
72
            supported_scenarios.append((test_name, scenario_info))
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
73
        else:
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
74
            unsupported_scenarios.append((test_name, scenario_info))
75
    result = loader.suiteClass()
76
    supported_tests = loader.loadTestsFromModuleNames([
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
77
        'breezy.tests.per_repository_chk.test_supported'])
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
78
    unsupported_tests = loader.loadTestsFromModuleNames([
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
79
        'breezy.tests.per_repository_chk.test_unsupported'])
3735.2.138 by Martin Pool
Clean up per_repository_chk to use multiply_tests
80
    multiply_tests(supported_tests, supported_scenarios, result)
81
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
3735.2.1 by Robert Collins
Add the concept of CHK lookups to Repository.
82
    return result