~bzr-pqm/bzr/bzr.dev

5387.2.7 by John Arbash Meinel
Merge bzr.dev 5444 to resolve some small text conflicts.
1
# Copyright (C) 2010 Canonical Ltd
5363.2.29 by Jelmer Vernooij
Move some bzrdir-specific tests to bzrlib.tests.per_bzrdir.
2
# Authors: Robert Collins <robert.collins@canonical.com>
3
#          Jelmer Vernooij <jelmer.vernooij@canonical.com>
4
# -*- coding: utf-8 -*-
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20
21
"""BzrDir implementation tests for bzr.
22
23
These test the conformance of all the bzrdir variations to the expected API.
24
Specific tests for individual formats are in the tests/test_bzrdir.py file
25
rather than in tests/per_branch/*.py. Generic control directory tests not
26
specific to BzrDir are in tests/per_controldir/*.py.
27
"""
28
29
from bzrlib.bzrdir import BzrDirFormat
30
from bzrlib.controldir import ControlDirFormat
31
from bzrlib.tests import (
32
    default_transport,
33
    multiply_tests,
34
    test_server,
35
    TestCaseWithTransport,
36
    )
37
from bzrlib.tests.per_controldir import make_scenarios
38
from bzrlib.transport import memory
39
40
41
class TestCaseWithBzrDir(TestCaseWithTransport):
42
43
    def setUp(self):
44
        super(TestCaseWithBzrDir, self).setUp()
45
        self.bzrdir = None
46
47
    def get_bzrdir(self):
48
        if self.bzrdir is None:
49
            self.bzrdir = self.make_bzrdir(None)
50
        return self.bzrdir
51
52
    def make_bzrdir(self, relpath, format=None):
53
        if format is None:
54
            format = self.bzrdir_format
55
        return super(TestCaseWithBzrDir, self).make_bzrdir(
56
            relpath, format=format)
57
58
59
def load_tests(standard_tests, module, loader):
60
    test_per_bzrdir = [
61
        'bzrlib.tests.per_bzrdir.test_bzrdir',
62
        ]
63
    submod_tests = loader.loadTestsFromModuleNames(test_per_bzrdir)
64
    formats = [format for format in ControlDirFormat.known_formats()
65
               if isinstance(format, BzrDirFormat)]
66
    scenarios = make_scenarios(
67
        default_transport,
68
        None,
69
        # None here will cause a readonly decorator to be created
70
        # by the TestCaseWithTransport.get_readonly_transport method.
71
        None,
72
        formats)
73
    # This will always add scenarios using the smart server.
74
    from bzrlib.remote import RemoteBzrDirFormat
75
    # test the remote server behaviour when backed with a MemoryTransport
76
    # Once for the current version
77
    scenarios.extend(make_scenarios(
78
        memory.MemoryServer,
79
        test_server.SmartTCPServer_for_testing,
80
        test_server.ReadonlySmartTCPServer_for_testing,
81
        [(RemoteBzrDirFormat())],
82
        name_suffix='-default'))
83
    # And once with < 1.6 - the 'v2' protocol.
84
    scenarios.extend(make_scenarios(
85
        memory.MemoryServer,
86
        test_server.SmartTCPServer_for_testing_v2_only,
87
        test_server.ReadonlySmartTCPServer_for_testing_v2_only,
88
        [(RemoteBzrDirFormat())],
89
        name_suffix='-v2'))
90
    # add the tests for the sub modules
91
    return multiply_tests(submod_tests, scenarios, standard_tests)