~bzr-pqm/bzr/bzr.dev

5361.3.7 by John Arbash Meinel
Merge bzr.dev 5390
1
# Copyright (C) 2006-2010 Canonical Ltd
1534.4.39 by Robert Collins
Basic BzrDir support.
2
# Authors: Robert Collins <robert.collins@canonical.com>
3
# -*- coding: utf-8 -*-
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
4
#
1534.4.39 by Robert Collins
Basic BzrDir support.
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
9
#
1534.4.39 by Robert Collins
Basic BzrDir support.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
14
#
1534.4.39 by Robert Collins
Basic BzrDir support.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1534.4.39 by Robert Collins
Basic BzrDir support.
18
19
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
20
"""ControlDir implementation tests for bzr.
1534.4.39 by Robert Collins
Basic BzrDir support.
21
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
22
These test the conformance of all the controldir variations to the expected API.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
23
Specific tests for individual formats are in the tests/test_bzrdir.py file
4523.1.1 by Martin Pool
Rename tests.branch_implementations to per_branch
24
rather than in tests/per_branch/*.py.
1534.4.39 by Robert Collins
Basic BzrDir support.
25
"""
26
5363.2.3 by Jelmer Vernooij
Add ControlDirFormat.
27
from bzrlib.controldir import ControlDirFormat
1534.4.39 by Robert Collins
Basic BzrDir support.
28
from bzrlib.tests import (
5017.3.24 by Vincent Ladeuil
selftest -s bt.test_selftest passing
29
    default_transport,
30
    multiply_tests,
31
    test_server,
32
    TestCaseWithTransport,
33
    )
5017.3.45 by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry.
34
from bzrlib.transport import memory
1534.4.39 by Robert Collins
Basic BzrDir support.
35
36
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
37
def make_scenarios(vfs_factory, transport_server, transport_readonly_server,
5609.9.3 by Vincent Ladeuil
Use self.get_transport() in per_controldir_colo and some cleanup.
38
                   formats, name_suffix=''):
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
39
    """Transform the input to a list of scenarios.
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
40
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
41
    :param formats: A list of bzrdir_format objects.
42
    :param vfs_server: A factory to create a Transport Server which has
43
        all the VFS methods working, and is writable.
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
44
    """
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
45
    result = []
46
    for format in formats:
47
        scenario_name = format.__class__.__name__
48
        scenario_name += name_suffix
49
        scenario = (scenario_name, {
50
            "vfs_transport_factory": vfs_factory,
51
            "transport_server": transport_server,
52
            "transport_readonly_server": transport_readonly_server,
53
            "bzrdir_format": format,
54
            })
55
        result.append(scenario)
56
    return result
2553.2.7 by Robert Collins
And overhaul BzrDirTestProviderAdapter too.
57
58
5363.2.18 by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir.
59
class TestCaseWithControlDir(TestCaseWithTransport):
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
60
61
    def setUp(self):
5363.2.18 by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir.
62
        super(TestCaseWithControlDir, self).setUp()
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
63
        self.bzrdir = None
64
65
    def get_bzrdir(self):
66
        if self.bzrdir is None:
67
            self.bzrdir = self.make_bzrdir(None)
68
        return self.bzrdir
69
70
    def make_bzrdir(self, relpath, format=None):
3242.2.14 by Aaron Bentley
Update from review comments
71
        if format is None:
72
            format = self.bzrdir_format
5363.2.18 by Jelmer Vernooij
Rename TestCaseWithBzrDir -> TestCaseWithControlDir.
73
        return super(TestCaseWithControlDir, self).make_bzrdir(
3242.2.14 by Aaron Bentley
Update from review comments
74
            relpath, format=format)
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
75
76
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
77
def load_tests(standard_tests, module, loader):
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
78
    test_per_controldir = [
79
        'bzrlib.tests.per_controldir.test_controldir',
5717.1.1 by Jelmer Vernooij
Support overriding check_supported.
80
        'bzrlib.tests.per_controldir.test_format',
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
81
        'bzrlib.tests.per_controldir.test_push',
1534.4.39 by Robert Collins
Basic BzrDir support.
82
        ]
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
83
    submod_tests = loader.loadTestsFromModuleNames(test_per_controldir)
5363.2.3 by Jelmer Vernooij
Add ControlDirFormat.
84
    formats = ControlDirFormat.known_formats()
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
85
    scenarios = make_scenarios(
1534.4.39 by Robert Collins
Basic BzrDir support.
86
        default_transport,
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
87
        None,
1534.4.39 by Robert Collins
Basic BzrDir support.
88
        # None here will cause a readonly decorator to be created
89
        # by the TestCaseWithTransport.get_readonly_transport method.
90
        None,
1733.1.3 by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs.
91
        formats)
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
92
    # This will always add scenarios using the smart server.
1752.2.87 by Andrew Bennetts
Make tests pass.
93
    from bzrlib.remote import RemoteBzrDirFormat
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
94
    # test the remote server behaviour when backed with a MemoryTransport
95
    # Once for the current version
96
    scenarios.extend(make_scenarios(
5017.3.45 by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry.
97
        memory.MemoryServer,
5017.3.24 by Vincent Ladeuil
selftest -s bt.test_selftest passing
98
        test_server.SmartTCPServer_for_testing,
99
        test_server.ReadonlySmartTCPServer_for_testing,
3453.5.1 by Andrew Bennetts
Add {bzrdir,repository,branch}_implementations tests for Remote objects using protocol v2 and pre-1.6 RPCs.
100
        [(RemoteBzrDirFormat())],
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
101
        name_suffix='-default'))
102
    # And once with < 1.6 - the 'v2' protocol.
103
    scenarios.extend(make_scenarios(
5017.3.45 by Vincent Ladeuil
Move MemoryServer back into bzrlib.transport.memory as it's needed as soon as a MemoryTransport is used. Add a NEWS entry.
104
        memory.MemoryServer,
5017.3.24 by Vincent Ladeuil
selftest -s bt.test_selftest passing
105
        test_server.SmartTCPServer_for_testing_v2_only,
106
        test_server.ReadonlySmartTCPServer_for_testing_v2_only,
3453.5.1 by Andrew Bennetts
Add {bzrdir,repository,branch}_implementations tests for Remote objects using protocol v2 and pre-1.6 RPCs.
107
        [(RemoteBzrDirFormat())],
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
108
        name_suffix='-v2'))
109
    # add the tests for the sub modules
110
    return multiply_tests(submod_tests, scenarios, standard_tests)