~bzr/ubuntu/lucid/bzr/beta-ppa

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_bzrdir_colo/test_unsupported.py

  • Committer: Martin Pool
  • Date: 2010-08-18 04:26:39 UTC
  • mfrom: (129.1.8 packaging-karmic)
  • Revision ID: mbp@sourcefrog.net-20100818042639-mjoxtngyjwiu05fo
* PPA rebuild for lucid.
* PPA rebuild for karmic.
* PPA rebuild onto jaunty.
* New upstream release.

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 bazaar control directories that do not support colocated branches.
 
18
 
 
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.
 
21
"""
 
22
 
 
23
from bzrlib import errors
 
24
from bzrlib.tests import (
 
25
    TestNotApplicable,
 
26
    )
 
27
from bzrlib.transport import (
 
28
    get_transport,
 
29
    )
 
30
 
 
31
from bzrlib.tests.per_bzrdir_colo import (
 
32
    TestCaseWithBzrDir,
 
33
    )
 
34
 
 
35
 
 
36
class TestNoColocatedSupport(TestCaseWithBzrDir):
 
37
 
 
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()
 
48
        return made_control
 
49
 
 
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
 
54
        self.assertRaises(
 
55
            (errors.NoColocatedBranchSupport, errors.UnsupportedOperation),
 
56
            branch.bzrdir.destroy_branch, 'colo')
 
57
 
 
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")
 
62
 
 
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")
 
67
 
 
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")