~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository_chk/__init__.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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
 
 
26
 
from bzrlib import (
27
 
    repository,
28
 
    remote,
29
 
    )
30
 
from bzrlib.repofmt.pack_repo import (
31
 
    RepositoryFormatKnitPack5,
32
 
    )
33
 
from bzrlib.repofmt.groupcompress_repo import (
34
 
    RepositoryFormatCHK1,
35
 
    )
36
 
from bzrlib.tests import (
37
 
    multiply_tests,
38
 
    )
39
 
from bzrlib.tests.per_repository import (
40
 
    all_repository_format_scenarios,
41
 
    TestCaseWithRepository,
42
 
    )
43
 
 
44
 
 
45
 
class TestCaseWithRepositoryCHK(TestCaseWithRepository):
46
 
 
47
 
    def make_repository(self, path, format=None):
48
 
        TestCaseWithRepository.make_repository(self, path, format=format)
49
 
        return repository.Repository.open(self.get_transport(path).base)
50
 
 
51
 
 
52
 
def load_tests(standard_tests, module, loader):
53
 
    supported_scenarios = []
54
 
    unsupported_scenarios = []
55
 
    for test_name, scenario_info in all_repository_format_scenarios():
56
 
        format = scenario_info['repository_format']
57
 
        # For remote repositories, we test both with, and without a backing chk
58
 
        # capable format: change the format we use to create the repo to direct
59
 
        # formats, and then the overridden make_repository in
60
 
        # TestCaseWithRepositoryCHK will give a re-opened RemoteRepository
61
 
        # with the chosen backing format.
62
 
        if isinstance(format, remote.RemoteRepositoryFormat):
63
 
            with_support = dict(scenario_info)
64
 
            with_support['repository_format'] = RepositoryFormatCHK1()
65
 
            supported_scenarios.append((test_name + "(Supported)", with_support))
66
 
            no_support = dict(scenario_info)
67
 
            no_support['repository_format'] = RepositoryFormatKnitPack5()
68
 
            unsupported_scenarios.append((test_name + "(Not Supported)", no_support))
69
 
        elif format.supports_chks:
70
 
            supported_scenarios.append((test_name, scenario_info))
71
 
        else:
72
 
            unsupported_scenarios.append((test_name, scenario_info))
73
 
    result = loader.suiteClass()
74
 
    supported_tests = loader.loadTestsFromModuleNames([
75
 
        'bzrlib.tests.per_repository_chk.test_supported'])
76
 
    unsupported_tests = loader.loadTestsFromModuleNames([
77
 
        'bzrlib.tests.per_repository_chk.test_unsupported'])
78
 
    multiply_tests(supported_tests, supported_scenarios, result)
79
 
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
80
 
    return result