~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_rmbranch.py

  • Committer: Aaron Bentley
  • Date: 2005-07-26 14:06:11 UTC
  • mto: (1092.1.41) (1185.3.4) (974.1.47)
  • mto: This revision was merged to the branch mainline in revision 982.
  • Revision ID: abentley@panoramicfeedback.com-20050726140611-403e366f3c79c1f1
Fixed python invocation

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
 
 
18
 
"""Black-box tests for bzr rmbranch."""
19
 
 
20
 
from bzrlib import (
21
 
    bzrdir,
22
 
    )
23
 
from bzrlib.tests import (
24
 
    TestCaseWithTransport,
25
 
    )
26
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
27
 
 
28
 
 
29
 
class TestRemoveBranch(TestCaseWithTransport):
30
 
 
31
 
    def example_branch(self, path='.', format=None):
32
 
        tree = self.make_branch_and_tree(path, format=format)
33
 
        self.build_tree_contents([(path + '/hello', 'foo')])
34
 
        tree.add('hello')
35
 
        tree.commit(message='setup')
36
 
        self.build_tree_contents([(path + '/goodbye', 'baz')])
37
 
        tree.add('goodbye')
38
 
        tree.commit(message='setup')
39
 
        return tree
40
 
 
41
 
    def test_remove_local(self):
42
 
        # Remove a local branch.
43
 
        self.example_branch('a')
44
 
        self.run_bzr('rmbranch a')
45
 
        dir = bzrdir.BzrDir.open('a')
46
 
        self.assertFalse(dir.has_branch())
47
 
        self.assertPathExists('a/hello')
48
 
        self.assertPathExists('a/goodbye')
49
 
 
50
 
    def test_no_branch(self):
51
 
        # No branch in the current directory. 
52
 
        self.make_repository('a')
53
 
        self.run_bzr_error(['Not a branch'],
54
 
            'rmbranch a')
55
 
 
56
 
    def test_no_arg(self):
57
 
        # location argument defaults to current directory
58
 
        self.example_branch('a')
59
 
        self.run_bzr('rmbranch', working_dir='a')
60
 
        dir = bzrdir.BzrDir.open('a')
61
 
        self.assertFalse(dir.has_branch())
62
 
 
63
 
    def test_remove_colo(self):
64
 
        # Remove a colocated branch.
65
 
        tree = self.example_branch('a', format='development-colo')
66
 
        tree.bzrdir.create_branch(name="otherbranch")
67
 
        self.assertTrue(tree.bzrdir.has_branch('otherbranch'))
68
 
        self.run_bzr('rmbranch %s,branch=otherbranch' % tree.bzrdir.user_url)
69
 
        dir = bzrdir.BzrDir.open('a')
70
 
        self.assertFalse(dir.has_branch('otherbranch'))
71
 
        self.assertTrue(dir.has_branch())
72
 
 
73
 
 
74
 
class TestSmartServerRemoveBranch(TestCaseWithTransport):
75
 
 
76
 
    def test_simple_remove_branch(self):
77
 
        self.setup_smart_server_with_call_log()
78
 
        self.make_branch('branch')
79
 
        self.reset_smart_call_log()
80
 
        out, err = self.run_bzr(['rmbranch', self.get_url('branch')])
81
 
        # This figure represent the amount of work to perform this use case. It
82
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
83
 
        # being too low. If rpc_count increases, more network roundtrips have
84
 
        # become necessary for this use case. Please do not adjust this number
85
 
        # upwards without agreement from bzr's network support maintainers.
86
 
        self.assertLength(5, self.hpss_calls)
87
 
        self.assertLength(1, self.hpss_connections)
88
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)