/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2052.3.1 by John Arbash Meinel
Add tests to cleanup the copyright of all source files
1
# Copyright (C) 2005, 2006 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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
16
"""Black-box tests for bzr aliases.
17
"""
18
19
import os
20
21
from bzrlib.branch import Branch
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
22
from bzrlib.tests import TestCaseWithTransport
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
23
from bzrlib.trace import mutter
1551.2.48 by abentley
Used ensure_config_dir exists instead of makedirs
24
from bzrlib.config import (ensure_config_dir_exists, config_filename)
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
25
1553.6.9 by Erik Bågfors
PEP8-ify
26
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
27
class TestAliases(TestCaseWithTransport):
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
28
29
    def test_aliases(self):
30
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
31
        def bzr(args, **kwargs):
32
            return self.run_bzr(args, **kwargs)[0]
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
33
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
34
        def bzr_catch_error(args, **kwargs):
35
            return self.run_bzr(args, **kwargs)[1]
1553.6.16 by Erik Bågfors
better test for --no-aliases
36
37
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
38
        if os.path.isfile(config_filename()):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
39
            # Something is wrong in environment,
40
            # we risk overwriting users config
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
41
            self.assert_(config_filename() + "exists, abort")
2664.6.2 by Daniel Watkins
tests.blackbox.test_aliases now uses internals where appropriate.
42
1551.2.48 by abentley
Used ensure_config_dir exists instead of makedirs
43
        ensure_config_dir_exists()
1553.6.7 by Erik Bågfors
test for option overrides
44
        CONFIG=("[ALIASES]\n"
45
                "c=cat\n"
46
                "c1=cat -r 1\n"
47
                "c2=cat -r 1 -r2\n")
48
49
        open(config_filename(),'wb').write(CONFIG)
50
51
        str1 = 'foo\n'
52
        str2 = 'bar\n'
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
53
2664.6.2 by Daniel Watkins
tests.blackbox.test_aliases now uses internals where appropriate.
54
        tree = self.make_branch_and_tree('.')
55
        self.build_tree_contents([('a', str1)])
56
        tree.add('a')
57
        tree.commit(message='1')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
58
59
        self.assertEquals(bzr('c a'), str1)
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
60
2664.6.2 by Daniel Watkins
tests.blackbox.test_aliases now uses internals where appropriate.
61
        self.build_tree_contents([('a', str2)])
62
        tree.commit(message='2')
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
63
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
64
        self.assertEquals(bzr('c a'), str2)
65
        self.assertEquals(bzr('c1 a'), str1)
66
        self.assertEquals(bzr('c1 --revision 2 a'), str2)
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
67
1553.6.16 by Erik Bågfors
better test for --no-aliases
68
        # If --no-aliases isn't working, we will not get retcode=3
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
69
        bzr('--no-aliases c a', retcode=3)
1553.6.6 by Erik Bågfors
blackbox tests for aliases,--no-aliases and aliases with options
70
1553.6.16 by Erik Bågfors
better test for --no-aliases
71
        # If --no-aliases breaks all of bzr, we also get retcode=3
72
        # So we need to catch the output as well
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
73
        self.assertEquals(bzr_catch_error('--no-aliases c a',
1740.5.6 by Martin Pool
Clean up many exception classes.
74
                                          retcode=None),
75
                          'bzr: ERROR: unknown command "c"\n')
1553.6.16 by Erik Bågfors
better test for --no-aliases
76
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
77
        bzr('c -r1 -r2', retcode=3)
78
        bzr('c1 -r1 -r2', retcode=3)
1553.6.7 by Erik Bågfors
test for option overrides
79
        bzr('c2', retcode=3)
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
80
        bzr('c2 -r1', retcode=3)