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 bzr directories that support colocated branches."""
20
from bzrlib import errors
21
from bzrlib.tests import (
24
from bzrlib.transport import (
28
from bzrlib.tests.per_bzrdir_colo import (
33
class TestColocatedBranchSupport(TestCaseWithBzrDir):
35
def test_destroy_colocated_branch(self):
36
branch = self.make_branch('branch')
37
bzrdir = branch.bzrdir
38
colo_branch = bzrdir.create_branch('colo')
39
bzrdir.destroy_branch("colo")
40
self.assertRaises(errors.NotBranchError, bzrdir.open_branch,
43
def test_create_colo_branch(self):
44
# a bzrdir can construct a branch and repository for itself.
45
if not self.bzrdir_format.is_supported():
46
# unsupported formats are not loopback testable
47
# because the default open will not open them and
48
# they may not be initializable.
49
raise TestNotApplicable('Control dir format not supported')
50
t = get_transport(self.get_url())
52
made_control = self.bzrdir_format.initialize(t.base)
53
except errors.UninitializableFormat:
54
raise TestNotApplicable('Control dir does not support creating '
56
made_repo = made_control.create_repository()
57
made_branch = made_control.create_branch("colo")
58
self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
59
self.assertEqual(made_control, made_branch.bzrdir)