5143.1.1
by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and |
1 |
# Copyright (C) 2010 Canonical Ltd
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
16 |
||
17 |
"""Tests for bzr directories that support colocated branches."""
|
|
18 |
||
19 |
import bzrlib.branch |
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
20 |
from bzrlib import ( |
21 |
errors, |
|
5609.9.3
by Vincent Ladeuil
Use self.get_transport() in per_controldir_colo and some cleanup. |
22 |
tests, |
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
23 |
transport, |
24 |
)
|
|
5143.1.1
by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and |
25 |
from bzrlib.tests import ( |
5609.9.3
by Vincent Ladeuil
Use self.get_transport() in per_controldir_colo and some cleanup. |
26 |
per_controldir, |
27 |
)
|
|
28 |
||
29 |
||
30 |
class TestColocatedBranchSupport(per_controldir.TestCaseWithControlDir): |
|
5143.1.1
by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and |
31 |
|
32 |
def test_destroy_colocated_branch(self): |
|
33 |
branch = self.make_branch('branch') |
|
34 |
bzrdir = branch.bzrdir |
|
35 |
colo_branch = bzrdir.create_branch('colo') |
|
5718.2.3
by Jelmer Vernooij
Allow destroy_branch without an argument to not be implemented. |
36 |
try: |
37 |
bzrdir.destroy_branch("colo") |
|
38 |
except (errors.UnsupportedOperation, errors.TransportNotPossible): |
|
39 |
raise tests.TestNotApplicable('Format does not support destroying branch') |
|
5609.9.3
by Vincent Ladeuil
Use self.get_transport() in per_controldir_colo and some cleanup. |
40 |
self.assertRaises(errors.NotBranchError, bzrdir.open_branch, |
5143.1.1
by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and |
41 |
"colo") |
42 |
||
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.
|
|
5609.9.3
by Vincent Ladeuil
Use self.get_transport() in per_controldir_colo and some cleanup. |
49 |
raise tests.TestNotApplicable('Control dir format not supported') |
50 |
t = self.get_transport() |
|
5143.1.2
by Jelmer Vernooij
Allow create_branch to raise UninitializableFormat. |
51 |
try: |
52 |
made_control = self.bzrdir_format.initialize(t.base) |
|
53 |
except errors.UninitializableFormat: |
|
5609.9.3
by Vincent Ladeuil
Use self.get_transport() in per_controldir_colo and some cleanup. |
54 |
raise tests.TestNotApplicable( |
55 |
'Control dir does not support creating new branches.') |
|
5143.1.1
by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and |
56 |
made_repo = made_control.create_repository() |
57 |
made_branch = made_control.create_branch("colo") |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
58 |
self.assertIsInstance(made_branch, bzrlib.branch.Branch) |
5143.1.1
by Jelmer Vernooij
Add separate tests for BzrDirs with colocated branch support and |
59 |
self.assertEqual(made_control, made_branch.bzrdir) |