~bzr-pqm/bzr/bzr.dev

5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
1
# Copyright (C) 2010 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
5143.1.3 by Jelmer Vernooij
Fix docstring.
18
"""BzrDir implementation tests for colocated branch support.
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
19
5143.1.3 by Jelmer Vernooij
Fix docstring.
20
These tests check the conformance of the colocated branches support.
21
All bzrdir formats are tested - those that do not suppport colocated branches 
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
22
have the test_unsupported tests run; the others have the test_supported tests
23
run.
24
"""
25
5363.2.3 by Jelmer Vernooij
Add ControlDirFormat.
26
from bzrlib.controldir import ControlDirFormat
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
27
from bzrlib.tests import (
28
    default_transport,
29
    multiply_tests,
6437.21.11 by Jelmer Vernooij
actually run per_controldir_colo tests against RemoteBzrDir.
30
    test_server,
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
31
    )
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
32
from bzrlib.tests.per_controldir import (
5363.2.18 by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir.
33
    TestCaseWithControlDir,
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
34
    make_scenarios,
35
    )
6437.21.11 by Jelmer Vernooij
actually run per_controldir_colo tests against RemoteBzrDir.
36
from bzrlib.transport import memory
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
37
38
39
def load_tests(standard_tests, module, loader):
40
    colo_supported_formats = []
41
    colo_unsupported_formats = []
6437.21.11 by Jelmer Vernooij
actually run per_controldir_colo tests against RemoteBzrDir.
42
    # This will always add scenarios using the smart server.
43
    from bzrlib.remote import RemoteBzrDirFormat
5363.2.3 by Jelmer Vernooij
Add ControlDirFormat.
44
    for format in ControlDirFormat.known_formats():
6437.21.11 by Jelmer Vernooij
actually run per_controldir_colo tests against RemoteBzrDir.
45
        if isinstance(format, RemoteBzrDirFormat):
46
            continue
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
47
        if format.colocated_branches:
48
            colo_supported_formats.append(format)
49
        else:
50
            colo_unsupported_formats.append(format)
51
    supported_scenarios = make_scenarios(default_transport, None, None,
52
        colo_supported_formats)
53
    unsupported_scenarios = make_scenarios(default_transport, None, None,
54
        colo_unsupported_formats)
6437.21.11 by Jelmer Vernooij
actually run per_controldir_colo tests against RemoteBzrDir.
55
    # test the remote server behaviour when backed with a MemoryTransport
56
    # Once for the current version
57
    unsupported_scenarios.extend(make_scenarios(
58
        memory.MemoryServer,
59
        test_server.SmartTCPServer_for_testing,
60
        test_server.ReadonlySmartTCPServer_for_testing,
61
        [(RemoteBzrDirFormat())],
62
        name_suffix='-default'))
63
    # And once with < 1.6 - the 'v2' protocol.
64
    unsupported_scenarios.extend(make_scenarios(
65
        memory.MemoryServer,
66
        test_server.SmartTCPServer_for_testing_v2_only,
67
        test_server.ReadonlySmartTCPServer_for_testing_v2_only,
68
        [(RemoteBzrDirFormat())],
69
        name_suffix='-v2'))
70
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
71
    result = loader.suiteClass()
72
    supported_tests = loader.loadTestsFromModuleNames([
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
73
        'bzrlib.tests.per_controldir_colo.test_supported'])
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
74
    unsupported_tests = loader.loadTestsFromModuleNames([
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
75
        'bzrlib.tests.per_controldir_colo.test_unsupported'])
5143.1.1 by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and
76
    multiply_tests(supported_tests, supported_scenarios, result)
77
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
78
    return result