1
# Copyright (C) 2010 Canonical Ltd
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.
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.
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
17
"""Tests for bazaar control directories that do not support colocated branches.
19
Colocated branch support is optional, and when it is not supported the methods
20
and attributes colocated branch support added should fail in known ways.
23
from bzrlib import errors
24
from bzrlib.tests import (
27
from bzrlib.transport import (
31
from bzrlib.tests.per_bzrdir_colo import (
36
class TestNoColocatedSupport(TestCaseWithBzrDir):
38
def make_bzrdir_with_repo(self):
39
# a bzrdir can construct a branch and repository for itself.
40
if not self.bzrdir_format.is_supported():
41
# unsupported formats are not loopback testable
42
# because the default open will not open them and
43
# they may not be initializable.
44
raise TestNotApplicable('Control dir format not supported')
45
t = get_transport(self.get_url())
46
made_control = self.bzrdir_format.initialize(t.base)
47
made_repo = made_control.create_repository()
50
def test_destroy_colocated_branch(self):
51
branch = self.make_branch('branch')
52
# Colocated branches should not be supported *or*
53
# destroy_branch should not be supported at all
55
(errors.NoColocatedBranchSupport, errors.UnsupportedOperation),
56
branch.bzrdir.destroy_branch, 'colo')
58
def test_create_colo_branch(self):
59
made_control = self.make_bzrdir_with_repo()
60
self.assertRaises(errors.NoColocatedBranchSupport,
61
made_control.create_branch, "colo")
63
def test_branch_transport(self):
64
made_control = self.make_bzrdir_with_repo()
65
self.assertRaises(errors.NoColocatedBranchSupport,
66
made_control.get_branch_transport, None, "colo")
68
def test_get_branch_reference(self):
69
made_control = self.make_bzrdir_with_repo()
70
self.assertRaises(errors.NoColocatedBranchSupport,
71
made_control.get_branch_reference, "colo")