/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Gary van der Merwe
  • Date: 2010-11-18 08:18:19 UTC
  • mto: This revision was merged to the branch mainline in revision 5543.
  • Revision ID: garyvdm@gmail.com-20101118081819-5bb84wrcl5gim8hb
Update test to match BranchBuilder change.

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 config."""
 
19
 
 
20
import os
 
21
 
 
22
from bzrlib import (
 
23
    config,
 
24
    errors,
 
25
    tests,
 
26
    )
 
27
from bzrlib.tests import (
 
28
    script,
 
29
    test_config as _t_config,
 
30
    )
 
31
 
 
32
class TestWithoutConfig(tests.TestCaseWithTransport):
 
33
 
 
34
    def test_config_all(self):
 
35
        out, err = self.run_bzr(['config'])
 
36
        self.assertEquals('', out)
 
37
        self.assertEquals('', err)
 
38
 
 
39
    def test_remove_unknown_option(self):
 
40
        self.run_bzr_error(['The "file" configuration option does not exist',],
 
41
                           ['config', '--remove', 'file'])
 
42
 
 
43
    def test_all_remove_exclusive(self):
 
44
        self.run_bzr_error(['--all and --remove are mutually exclusive.',],
 
45
                           ['config', '--remove', '--all'])
 
46
 
 
47
    def test_all_set_exclusive(self):
 
48
        self.run_bzr_error(['Only one option can be set.',],
 
49
                           ['config', '--all', 'hello=world'])
 
50
 
 
51
    def test_remove_no_option(self):
 
52
        self.run_bzr_error(['--remove expects an option to remove.',],
 
53
                           ['config', '--remove'])
 
54
 
 
55
    def test_unknown_option(self):
 
56
        self.run_bzr_error(['The "file" configuration option does not exist',],
 
57
                           ['config', 'file'])
 
58
 
 
59
    def test_unexpected_regexp(self):
 
60
        self.run_bzr_error(
 
61
            ['The "\*file" configuration option does not exist',],
 
62
            ['config', '*file'])
 
63
 
 
64
    def test_wrong_regexp(self):
 
65
        self.run_bzr_error(
 
66
            ['Invalid pattern\(s\) found. "\*file" nothing to repeat',],
 
67
            ['config', '--all', '*file'])
 
68
 
 
69
 
 
70
 
 
71
class TestConfigDisplay(tests.TestCaseWithTransport):
 
72
 
 
73
    def setUp(self):
 
74
        super(TestConfigDisplay, self).setUp()
 
75
        _t_config.create_configs(self)
 
76
 
 
77
    def test_bazaar_config(self):
 
78
        self.bazaar_config.set_user_option('hello', 'world')
 
79
        script.run_script(self, '''\
 
80
            $ bzr config -d tree
 
81
            bazaar:
 
82
              hello = world
 
83
            ''')
 
84
 
 
85
    def test_locations_config_for_branch(self):
 
86
        self.locations_config.set_user_option('hello', 'world')
 
87
        self.branch_config.set_user_option('hello', 'you')
 
88
        script.run_script(self, '''\
 
89
            $ bzr config -d tree
 
90
            locations:
 
91
              hello = world
 
92
            branch:
 
93
              hello = you
 
94
            ''')
 
95
 
 
96
    def test_locations_config_outside_branch(self):
 
97
        self.bazaar_config.set_user_option('hello', 'world')
 
98
        self.locations_config.set_user_option('hello', 'world')
 
99
        script.run_script(self, '''\
 
100
            $ bzr config
 
101
            bazaar:
 
102
              hello = world
 
103
            ''')
 
104
 
 
105
 
 
106
class TestConfigActive(tests.TestCaseWithTransport):
 
107
 
 
108
    def setUp(self):
 
109
        super(TestConfigActive, self).setUp()
 
110
        _t_config.create_configs_with_file_option(self)
 
111
 
 
112
    def test_active_in_locations(self):
 
113
        script.run_script(self, '''\
 
114
            $ bzr config -d tree file
 
115
            locations
 
116
            ''')
 
117
 
 
118
    def test_active_in_bazaar(self):
 
119
        script.run_script(self, '''\
 
120
            $ bzr config -d tree --scope bazaar file
 
121
            bazaar
 
122
            ''')
 
123
 
 
124
    def test_active_in_branch(self):
 
125
        # We need to delete the locations definition that overrides the branch
 
126
        # one
 
127
        script.run_script(self, '''\
 
128
            $ bzr config -d tree --remove file
 
129
            $ bzr config -d tree file
 
130
            branch
 
131
            ''')
 
132
 
 
133
 
 
134
class TestConfigSetOption(tests.TestCaseWithTransport):
 
135
 
 
136
    def setUp(self):
 
137
        super(TestConfigSetOption, self).setUp()
 
138
        _t_config.create_configs(self)
 
139
 
 
140
    def test_unknown_config(self):
 
141
        self.run_bzr_error(['The "moon" configuration does not exist'],
 
142
                           ['config', '--scope', 'moon', 'hello=world'])
 
143
 
 
144
    def test_bazaar_config_outside_branch(self):
 
145
        script.run_script(self, '''\
 
146
            $ bzr config --scope bazaar hello=world
 
147
            $ bzr config -d tree --all hello
 
148
            bazaar:
 
149
              hello = world
 
150
            ''')
 
151
 
 
152
    def test_bazaar_config_inside_branch(self):
 
153
        script.run_script(self, '''\
 
154
            $ bzr config -d tree --scope bazaar hello=world
 
155
            $ bzr config -d tree --all hello
 
156
            bazaar:
 
157
              hello = world
 
158
            ''')
 
159
 
 
160
    def test_locations_config_inside_branch(self):
 
161
        script.run_script(self, '''\
 
162
            $ bzr config -d tree --scope locations hello=world
 
163
            $ bzr config -d tree --all hello
 
164
            locations:
 
165
              hello = world
 
166
            ''')
 
167
 
 
168
    def test_branch_config_default(self):
 
169
        script.run_script(self, '''\
 
170
            $ bzr config -d tree hello=world
 
171
            $ bzr config -d tree --all hello
 
172
            branch:
 
173
              hello = world
 
174
            ''')
 
175
 
 
176
    def test_branch_config_forcing_branch(self):
 
177
        script.run_script(self, '''\
 
178
            $ bzr config -d tree --scope branch hello=world
 
179
            $ bzr config -d tree --all hello
 
180
            branch:
 
181
              hello = world
 
182
            ''')
 
183
 
 
184
 
 
185
class TestConfigRemoveOption(tests.TestCaseWithTransport):
 
186
 
 
187
    def setUp(self):
 
188
        super(TestConfigRemoveOption, self).setUp()
 
189
        _t_config.create_configs_with_file_option(self)
 
190
 
 
191
    def test_unknown_config(self):
 
192
        self.run_bzr_error(['The "moon" configuration does not exist'],
 
193
                           ['config', '--scope', 'moon', '--remove', 'file'])
 
194
 
 
195
    def test_bazaar_config_outside_branch(self):
 
196
        script.run_script(self, '''\
 
197
            $ bzr config --scope bazaar --remove file
 
198
            $ bzr config -d tree --all file
 
199
            locations:
 
200
              file = locations
 
201
            branch:
 
202
              file = branch
 
203
            ''')
 
204
 
 
205
    def test_bazaar_config_inside_branch(self):
 
206
        script.run_script(self, '''\
 
207
            $ bzr config -d tree --scope bazaar --remove file
 
208
            $ bzr config -d tree --all file
 
209
            locations:
 
210
              file = locations
 
211
            branch:
 
212
              file = branch
 
213
            ''')
 
214
 
 
215
    def test_locations_config_inside_branch(self):
 
216
        script.run_script(self, '''\
 
217
            $ bzr config -d tree --scope locations --remove file
 
218
            $ bzr config -d tree --all file
 
219
            branch:
 
220
              file = branch
 
221
            bazaar:
 
222
              file = bazaar
 
223
            ''')
 
224
 
 
225
    def test_branch_config_default(self):
 
226
        script.run_script(self, '''\
 
227
            $ bzr config -d tree --remove file
 
228
            $ bzr config -d tree --all file
 
229
            branch:
 
230
              file = branch
 
231
            bazaar:
 
232
              file = bazaar
 
233
            ''')
 
234
        script.run_script(self, '''\
 
235
            $ bzr config -d tree --remove file
 
236
            $ bzr config -d tree --all file
 
237
            bazaar:
 
238
              file = bazaar
 
239
            ''')
 
240
 
 
241
    def test_branch_config_forcing_branch(self):
 
242
        script.run_script(self, '''\
 
243
            $ bzr config -d tree --scope branch --remove file
 
244
            $ bzr config -d tree --all file
 
245
            locations:
 
246
              file = locations
 
247
            bazaar:
 
248
              file = bazaar
 
249
            ''')
 
250
        script.run_script(self, '''\
 
251
            $ bzr config -d tree --remove file
 
252
            $ bzr config -d tree --all file
 
253
            bazaar:
 
254
              file = bazaar
 
255
            ''')