1
# Copyright (C) 2006-2010 Canonical Ltd
2
# Authors: Robert Collins <robert.collins@canonical.com>
3
# Jelmer Vernooij <jelmer.vernooij@canonical.com>
4
# -*- coding: utf-8 -*-
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.
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.
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
21
"""BzrDir implementation tests for bzr.
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.
29
from bzrlib.bzrdir import BzrDirFormat
30
from bzrlib.controldir import ControlDirFormat
31
from bzrlib.tests import (
35
TestCaseWithTransport,
37
from bzrlib.tests.per_controldir import make_scenarios
38
from bzrlib.transport import memory
41
class TestCaseWithBzrDir(TestCaseWithTransport):
44
super(TestCaseWithBzrDir, self).setUp()
48
if self.bzrdir is None:
49
self.bzrdir = self.make_bzrdir(None)
52
def make_bzrdir(self, relpath, format=None):
54
format = self.bzrdir_format
55
return super(TestCaseWithBzrDir, self).make_bzrdir(
56
relpath, format=format)
59
def load_tests(standard_tests, module, loader):
61
'bzrlib.tests.per_bzrdir.test_bzrdir',
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(
69
# None here will cause a readonly decorator to be created
70
# by the TestCaseWithTransport.get_readonly_transport method.
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(
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(
86
test_server.SmartTCPServer_for_testing_v2_only,
87
test_server.ReadonlySmartTCPServer_for_testing_v2_only,
88
[(RemoteBzrDirFormat())],
90
# add the tests for the sub modules
91
return multiply_tests(submod_tests, scenarios, standard_tests)