1
# Copyright (C) 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
"""Black-box tests for bzr config."""
27
from bzrlib.tests import (
29
test_config as _t_config,
32
class TestWithoutConfig(tests.TestCaseWithTransport):
34
def test_config_all(self):
35
out, err = self.run_bzr(['config'])
36
self.assertEquals('', out)
37
self.assertEquals('', err)
39
def test_remove_unknown_option(self):
40
self.run_bzr_error(['The "file" configuration option does not exist',],
41
['config', '--remove', 'file'])
43
def test_all_remove_exclusive(self):
44
self.run_bzr_error(['--all and --remove are mutually exclusive.',],
45
['config', '--remove', '--all'])
47
def test_all_set_exclusive(self):
48
self.run_bzr_error(['Only one option can be set.',],
49
['config', '--all', 'hello=world'])
51
def test_remove_no_option(self):
52
self.run_bzr_error(['--remove expects an option to remove.',],
53
['config', '--remove'])
55
def test_unknown_option(self):
56
self.run_bzr_error(['The "file" configuration option does not exist',],
59
def test_unexpected_regexp(self):
61
['The "\*file" configuration option does not exist',],
64
def test_wrong_regexp(self):
66
['Invalid pattern\(s\) found. "\*file" nothing to repeat',],
67
['config', '--all', '*file'])
71
class TestConfigDisplay(tests.TestCaseWithTransport):
74
super(TestConfigDisplay, self).setUp()
75
_t_config.create_configs(self)
77
def test_bazaar_config(self):
78
self.bazaar_config.set_user_option('hello', 'world')
79
script.run_script(self, '''\
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, '''\
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, '''\
106
class TestConfigActive(tests.TestCaseWithTransport):
109
super(TestConfigActive, self).setUp()
110
_t_config.create_configs_with_file_option(self)
112
def test_active_in_locations(self):
113
script.run_script(self, '''\
114
$ bzr config -d tree file
118
def test_active_in_bazaar(self):
119
script.run_script(self, '''\
120
$ bzr config -d tree --scope bazaar file
124
def test_active_in_branch(self):
125
# We need to delete the locations definition that overrides the branch
127
script.run_script(self, '''\
128
$ bzr config -d tree --remove file
129
$ bzr config -d tree file
134
class TestConfigSetOption(tests.TestCaseWithTransport):
137
super(TestConfigSetOption, self).setUp()
138
_t_config.create_configs(self)
140
def test_unknown_config(self):
141
self.run_bzr_error(['The "moon" configuration does not exist'],
142
['config', '--scope', 'moon', 'hello=world'])
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
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
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
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
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
185
class TestConfigRemoveOption(tests.TestCaseWithTransport):
188
super(TestConfigRemoveOption, self).setUp()
189
_t_config.create_configs_with_file_option(self)
191
def test_unknown_config(self):
192
self.run_bzr_error(['The "moon" configuration does not exist'],
193
['config', '--scope', 'moon', '--remove', 'file'])
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
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
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
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
234
script.run_script(self, '''\
235
$ bzr config -d tree --remove file
236
$ bzr config -d tree --all file
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
250
script.run_script(self, '''\
251
$ bzr config -d tree --remove file
252
$ bzr config -d tree --all file