~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir_colo/test_supported.py

  • Committer: Martin Pool
  • Date: 2010-04-01 04:41:18 UTC
  • mto: This revision was merged to the branch mainline in revision 5128.
  • Revision ID: mbp@sourcefrog.net-20100401044118-shyctqc02ob08ngz
ignore .testrepository

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
20
 
from bzrlib import errors
21
 
from bzrlib.tests import (
22
 
    TestNotApplicable,
23
 
    )
24
 
from bzrlib.transport import (
25
 
    get_transport,
26
 
    )
27
 
 
28
 
from bzrlib.tests.per_controldir_colo import (
29
 
    TestCaseWithControlDir,
30
 
    )
31
 
 
32
 
 
33
 
class TestColocatedBranchSupport(TestCaseWithControlDir):
34
 
 
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, 
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.
49
 
            raise TestNotApplicable('Control dir format not supported')
50
 
        t = get_transport(self.get_url())
51
 
        try:
52
 
            made_control = self.bzrdir_format.initialize(t.base)
53
 
        except errors.UninitializableFormat:
54
 
            raise TestNotApplicable('Control dir does not support creating '
55
 
                'new branches.')
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)