~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-05-04 01:31:48 UTC
  • mto: (1697.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: robertc@robertcollins.net-20060504013148-74208691b1b4857e
Add stdin parameter to run_bzr and run_bzr_captured.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 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
 
"""Tests of the 'bzr alias' command."""
19
 
 
20
 
from bzrlib import (
21
 
    config,
22
 
    tests,
23
 
    )
24
 
 
25
 
 
26
 
class TestAlias(tests.TestCaseWithTransport):
27
 
 
28
 
    def test_list_alias_with_none(self):
29
 
        """Calling alias with no parameters lists existing aliases."""
30
 
        out, err = self.run_bzr('alias')
31
 
        self.assertEquals('', out)
32
 
 
33
 
    def test_list_unknown_alias(self):
34
 
        out, err = self.run_bzr('alias commit')
35
 
        self.assertEquals('bzr alias: commit: not found\n', out)
36
 
 
37
 
    def test_add_alias_outputs_nothing(self):
38
 
        out, err = self.run_bzr('alias commit="commit --strict"')
39
 
        self.assertEquals('', out)
40
 
 
41
 
    def test_add_alias_visible(self):
42
 
        """Adding an alias makes it ..."""
43
 
        self.run_bzr('alias commit="commit --strict"')
44
 
        out, err = self.run_bzr('alias commit')
45
 
        self.assertEquals('bzr alias commit="commit --strict"\n', out)
46
 
 
47
 
    def test_unicode_alias(self):
48
 
        """Unicode aliases should work (Bug #529930)"""
49
 
        # XXX: strictly speaking, lack of unicode filenames doesn't imply that
50
 
        # unicode command lines aren't available.
51
 
        self.requireFeature(tests.UnicodeFilenameFeature)
52
 
        file_name = u'foo\xb6'
53
 
 
54
 
        tree = self.make_branch_and_tree('.')
55
 
        self.build_tree([file_name])
56
 
        tree.add(file_name)
57
 
        tree.commit('added')
58
 
 
59
 
        config.GlobalConfig.from_string(
60
 
            u'[ALIASES]\nust=st %s\n' % (file_name,), save=True)
61
 
 
62
 
        out, err = self.run_bzr('ust')
63
 
        self.assertEquals(err, '')
64
 
        self.assertEquals(out, '')
65
 
 
66
 
    def test_alias_listing_alphabetical(self):
67
 
        self.run_bzr('alias commit="commit --strict"')
68
 
        self.run_bzr('alias ll="log --short"')
69
 
        self.run_bzr('alias add="add -q"')
70
 
 
71
 
        out, err = self.run_bzr('alias')
72
 
        self.assertEquals(
73
 
            'bzr alias add="add -q"\n'
74
 
            'bzr alias commit="commit --strict"\n'
75
 
            'bzr alias ll="log --short"\n',
76
 
            out)
77
 
 
78
 
    def test_remove_unknown_alias(self):
79
 
        out, err = self.run_bzr('alias --remove fooix', retcode=3)
80
 
        self.assertEquals('bzr: ERROR: The alias "fooix" does not exist.\n',
81
 
                          err)
82
 
 
83
 
    def test_remove_known_alias(self):
84
 
        self.run_bzr('alias commit="commit --strict"')
85
 
        out, err = self.run_bzr('alias commit')
86
 
        self.assertEquals('bzr alias commit="commit --strict"\n', out)
87
 
        # No output when removing an existing alias.
88
 
        out, err = self.run_bzr('alias --remove commit')
89
 
        self.assertEquals('', out)
90
 
        # Now its not.
91
 
        out, err = self.run_bzr('alias commit')
92
 
        self.assertEquals("bzr alias: commit: not found\n", out)