1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
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.
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.
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
18
"""Tests of the 'bzr alias' command."""
22
from bzrlib.tests import TestCaseWithTransport
23
from bzrlib.config import (ensure_config_dir_exists, config_filename)
26
class TestAlias(TestCaseWithTransport):
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)
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)
37
def test_add_alias_outputs_nothing(self):
38
out, err = self.run_bzr('alias commit="commit --strict"')
39
self.assertEquals('', out)
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)
47
def test_unicode_alias(self):
48
"""Unicode aliases should work (Bug #529930)"""
50
file_name = u'foo\xb6'
52
tree = self.make_branch_and_tree('.')
53
self.build_tree([file_name])
57
ensure_config_dir_exists()
58
CONFIG=(u'[ALIASES]\n'
61
codecs.open(config_filename(),'w', config_enc).write(CONFIG)
63
out, err = self.run_bzr('ust')
64
self.assertEquals(err, '')
65
self.assertEquals(out, '')
67
def test_alias_listing_alphabetical(self):
68
self.run_bzr('alias commit="commit --strict"')
69
self.run_bzr('alias ll="log --short"')
70
self.run_bzr('alias add="add -q"')
72
out, err = self.run_bzr('alias')
74
'bzr alias add="add -q"\n'
75
'bzr alias commit="commit --strict"\n'
76
'bzr alias ll="log --short"\n',
79
def test_remove_unknown_alias(self):
80
out, err = self.run_bzr('alias --remove fooix', retcode=3)
81
self.assertEquals('bzr: ERROR: The alias "fooix" does not exist.\n',
84
def test_remove_known_alias(self):
85
self.run_bzr('alias commit="commit --strict"')
86
out, err = self.run_bzr('alias commit')
87
self.assertEquals('bzr alias commit="commit --strict"\n', out)
88
# No output when removing an existing alias.
89
out, err = self.run_bzr('alias --remove commit')
90
self.assertEquals('', out)
92
out, err = self.run_bzr('alias commit')
93
self.assertEquals("bzr alias: commit: not found\n", out)