5273.1.8
by Vincent Ladeuil
Merge bzr.dev into cleanup |
1 |
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
|
2900.3.6
by Tim Penhey
Added tests. |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2900.3.6
by Tim Penhey
Added tests. |
16 |
#
|
17 |
||
18 |
"""Tests of the 'bzr alias' command."""
|
|
5345.1.18
by Vincent Ladeuil
Cleanup bb.test_alias. |
19 |
|
20 |
from bzrlib import ( |
|
21 |
config, |
|
22 |
tests, |
|
23 |
)
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
24 |
from bzrlib.tests import ( |
25 |
features, |
|
26 |
)
|
|
5345.1.18
by Vincent Ladeuil
Cleanup bb.test_alias. |
27 |
|
28 |
||
29 |
class TestAlias(tests.TestCaseWithTransport): |
|
2900.3.6
by Tim Penhey
Added tests. |
30 |
|
31 |
def test_list_alias_with_none(self): |
|
32 |
"""Calling alias with no parameters lists existing aliases."""
|
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
33 |
out, err = self.run_bzr('alias') |
2900.3.6
by Tim Penhey
Added tests. |
34 |
self.assertEquals('', out) |
35 |
||
36 |
def test_list_unknown_alias(self): |
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
37 |
out, err = self.run_bzr('alias commit') |
38 |
self.assertEquals('bzr alias: commit: not found\n', out) |
|
2900.3.6
by Tim Penhey
Added tests. |
39 |
|
40 |
def test_add_alias_outputs_nothing(self): |
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
41 |
out, err = self.run_bzr('alias commit="commit --strict"') |
2900.3.6
by Tim Penhey
Added tests. |
42 |
self.assertEquals('', out) |
43 |
||
44 |
def test_add_alias_visible(self): |
|
45 |
"""Adding an alias makes it ..."""
|
|
46 |
self.run_bzr('alias commit="commit --strict"') |
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
47 |
out, err = self.run_bzr('alias commit') |
48 |
self.assertEquals('bzr alias commit="commit --strict"\n', out) |
|
2900.3.6
by Tim Penhey
Added tests. |
49 |
|
5158.7.1
by Parth Malwankar
added fail case test for unicode alias |
50 |
def test_unicode_alias(self): |
51 |
"""Unicode aliases should work (Bug #529930)"""
|
|
5050.37.1
by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C. |
52 |
# XXX: strictly speaking, lack of unicode filenames doesn't imply that
|
53 |
# unicode command lines aren't available.
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
54 |
self.requireFeature(features.UnicodeFilenameFeature) |
5158.7.12
by Parth Malwankar
updated test to work on windows |
55 |
file_name = u'foo\xb6' |
5158.7.7
by Parth Malwankar
updated test case to use user_encoding instead of utf-8 |
56 |
|
5158.7.15
by Parth Malwankar
test cleanup. |
57 |
tree = self.make_branch_and_tree('.') |
58 |
self.build_tree([file_name]) |
|
59 |
tree.add(file_name) |
|
60 |
tree.commit('added') |
|
5158.7.2
by Parth Malwankar
intermediate checkin of test case |
61 |
|
5345.1.26
by Vincent Ladeuil
Merge lockable-config-files into remove-gratuitous-ensure-config-dir-exist-calls resolving conflicts |
62 |
config.GlobalConfig.from_string( |
63 |
u'[ALIASES]\nust=st %s\n' % (file_name,), save=True) |
|
5158.7.12
by Parth Malwankar
updated test to work on windows |
64 |
|
65 |
out, err = self.run_bzr('ust') |
|
5158.7.5
by Parth Malwankar
unicode aliases work now. |
66 |
self.assertEquals(err, '') |
5158.7.12
by Parth Malwankar
updated test to work on windows |
67 |
self.assertEquals(out, '') |
5158.7.1
by Parth Malwankar
added fail case test for unicode alias |
68 |
|
2900.3.6
by Tim Penhey
Added tests. |
69 |
def test_alias_listing_alphabetical(self): |
70 |
self.run_bzr('alias commit="commit --strict"') |
|
71 |
self.run_bzr('alias ll="log --short"') |
|
72 |
self.run_bzr('alias add="add -q"') |
|
73 |
||
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
74 |
out, err = self.run_bzr('alias') |
2900.3.6
by Tim Penhey
Added tests. |
75 |
self.assertEquals( |
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
76 |
'bzr alias add="add -q"\n' |
77 |
'bzr alias commit="commit --strict"\n' |
|
78 |
'bzr alias ll="log --short"\n', |
|
79 |
out) |
|
2900.3.6
by Tim Penhey
Added tests. |
80 |
|
81 |
def test_remove_unknown_alias(self): |
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
82 |
out, err = self.run_bzr('alias --remove fooix', retcode=3) |
83 |
self.assertEquals('bzr: ERROR: The alias "fooix" does not exist.\n', |
|
84 |
err) |
|
2900.3.6
by Tim Penhey
Added tests. |
85 |
|
86 |
def test_remove_known_alias(self): |
|
87 |
self.run_bzr('alias commit="commit --strict"') |
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
88 |
out, err = self.run_bzr('alias commit') |
89 |
self.assertEquals('bzr alias commit="commit --strict"\n', out) |
|
2900.3.6
by Tim Penhey
Added tests. |
90 |
# No output when removing an existing alias.
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
91 |
out, err = self.run_bzr('alias --remove commit') |
2900.3.6
by Tim Penhey
Added tests. |
92 |
self.assertEquals('', out) |
93 |
# Now its not.
|
|
2900.3.11
by Tim Penhey
Fixed the output in the tests. |
94 |
out, err = self.run_bzr('alias commit') |
95 |
self.assertEquals("bzr alias: commit: not found\n", out) |