/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
27
from breezy.controldir import ControlDirFormat
28
from breezy.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
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
34
from breezy.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()
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
63
        self.controldir = None
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
64
65
    def get_bzrdir(self):
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
66
        if self.controldir is None:
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
67
            self.controldir = self.make_controldir(None)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
68
        return self.controldir
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
69
6155.6.11 by Jelmer Vernooij
Fix per_controldir/per_bzrdir tests.
70
    def get_default_format(self):
71
        return self.bzrdir_format
2475.3.1 by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport()
72
73
6625.1.5 by Martin
Drop custom load_tests implementation and use unittest signature
74
def load_tests(loader, standard_tests, pattern):
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
75
    test_per_controldir = [
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
76
        'breezy.tests.per_controldir.test_controldir',
77
        'breezy.tests.per_controldir.test_format',
78
        'breezy.tests.per_controldir.test_push',
1534.4.39 by Robert Collins
Basic BzrDir support.
79
        ]
5363.2.2 by Jelmer Vernooij
Rename per_bzrdir => per_controldir.
80
    submod_tests = loader.loadTestsFromModuleNames(test_per_controldir)
5363.2.3 by Jelmer Vernooij
Add ControlDirFormat.
81
    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.
82
    scenarios = make_scenarios(
1534.4.39 by Robert Collins
Basic BzrDir support.
83
        default_transport,
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
84
        None,
1534.4.39 by Robert Collins
Basic BzrDir support.
85
        # None here will cause a readonly decorator to be created
86
        # by the TestCaseWithTransport.get_readonly_transport method.
87
        None,
1733.1.3 by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs.
88
        formats)
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
89
    # This will always add scenarios using the smart server.
6670.4.14 by Jelmer Vernooij
Move remote to breezy.bzr.
90
    from breezy.bzr.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.
91
    # test the remote server behaviour when backed with a MemoryTransport
92
    # Once for the current version
93
    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.
94
        memory.MemoryServer,
5017.3.24 by Vincent Ladeuil
selftest -s bt.test_selftest passing
95
        test_server.SmartTCPServer_for_testing,
96
        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.
97
        [(RemoteBzrDirFormat())],
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
98
        name_suffix='-default'))
99
    # And once with < 1.6 - the 'v2' protocol.
100
    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.
101
        memory.MemoryServer,
5017.3.24 by Vincent Ladeuil
selftest -s bt.test_selftest passing
102
        test_server.SmartTCPServer_for_testing_v2_only,
103
        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.
104
        [(RemoteBzrDirFormat())],
4084.5.1 by Robert Collins
Bulk update all test adaptation into a single approach, using multiply_tests rather than test adapters.
105
        name_suffix='-v2'))
106
    # add the tests for the sub modules
107
    return multiply_tests(submod_tests, scenarios, standard_tests)