18
18
"""Black-box tests for bzr config."""
22
20
from bzrlib import (
27
24
from bzrlib.tests import (
29
26
test_config as _t_config,
28
from bzrlib.tests.matchers import ContainsNoVfsCalls
32
31
class TestWithoutConfig(tests.TestCaseWithTransport):
34
def test_no_config(self):
33
def test_config_all(self):
35
34
out, err = self.run_bzr(['config'])
36
35
self.assertEquals('', out)
37
36
self.assertEquals('', err)
39
def test_all_variables_no_config(self):
40
out, err = self.run_bzr(['config', '*'])
41
self.assertEquals('', out)
42
self.assertEquals('', err)
38
def test_remove_unknown_option(self):
39
self.run_bzr_error(['The "file" configuration option does not exist',],
40
['config', '--remove', 'file'])
42
def test_all_remove_exclusive(self):
43
self.run_bzr_error(['--all and --remove are mutually exclusive.',],
44
['config', '--remove', '--all'])
46
def test_all_set_exclusive(self):
47
self.run_bzr_error(['Only one option can be set.',],
48
['config', '--all', 'hello=world'])
50
def test_remove_no_option(self):
51
self.run_bzr_error(['--remove expects an option to remove.',],
52
['config', '--remove'])
44
54
def test_unknown_option(self):
45
55
self.run_bzr_error(['The "file" configuration option does not exist',],
46
['config', '--remove', 'file'])
58
def test_unexpected_regexp(self):
60
['The "\*file" configuration option does not exist',],
63
def test_wrong_regexp(self):
65
['Invalid pattern\(s\) found. "\*file" nothing to repeat',],
66
['config', '--all', '*file'])
48
70
class TestConfigDisplay(tests.TestCaseWithTransport):
51
73
super(TestConfigDisplay, self).setUp()
52
74
_t_config.create_configs(self)
76
def test_multiline_all_values(self):
77
self.bazaar_config.set_user_option('multiline', '1\n2\n')
78
# Fallout from bug 710410, the triple quotes have been toggled
79
script.run_script(self, '''\
87
def test_multiline_value_only(self):
88
self.bazaar_config.set_user_option('multiline', '1\n2\n')
89
# Fallout from bug 710410, the triple quotes have been toggled
90
script.run_script(self, '''\
91
$ bzr config -d tree multiline
97
def test_list_all_values(self):
98
# FIXME: we should register the option as a list or it's displayed as
99
# astring and as such, quoted.
100
self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
101
script.run_script(self, '''\
104
list = '1, a, "with, a comma"'
107
def test_list_value_only(self):
108
# FIXME: we should register the option as a list or it's displayed as
109
# astring and as such, quoted.
110
self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
111
script.run_script(self, '''\
112
$ bzr config -d tree list
113
'1, a, "with, a comma"'
54
116
def test_bazaar_config(self):
55
117
self.bazaar_config.set_user_option('hello', 'world')
56
118
script.run_script(self, '''\
145
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
147
def test_location_with_policy(self):
148
# LocationConfig is the only one dealing with policies so far.
149
self.make_branch_and_tree('tree')
153
url:policy = appendpath
156
""" % {'dir': self.test_dir}
157
# We don't use the config directly so we save it to disk
158
config.LocationConfig.from_string(config_text, 'tree', save=True)
159
# policies are displayed with their options since they are part of
160
# their definition, likewise the path is not appended, we are just
161
# presenting the relevant portions of the config files
162
script.run_script(self, '''\
163
$ bzr config -d tree --all url
169
url:policy = appendpath
173
class TestConfigActive(tests.TestCaseWithTransport):
176
super(TestConfigActive, self).setUp()
177
_t_config.create_configs_with_file_option(self)
179
def test_active_in_locations(self):
180
script.run_script(self, '''\
181
$ bzr config -d tree file
185
def test_active_in_bazaar(self):
186
script.run_script(self, '''\
187
$ bzr config -d tree --scope bazaar file
191
def test_active_in_branch(self):
192
# We need to delete the locations definition that overrides the branch
194
script.run_script(self, '''\
195
$ bzr config -d tree --scope locations --remove file
196
$ bzr config -d tree file
83
201
class TestConfigSetOption(tests.TestCaseWithTransport):
109
227
def test_locations_config_inside_branch(self):
110
228
script.run_script(self, '''\
111
229
$ bzr config -d tree --scope locations hello=world
112
$ bzr config -d tree hello
230
$ bzr config -d tree --all hello
117
236
def test_branch_config_default(self):
118
237
script.run_script(self, '''\
119
238
$ bzr config -d tree hello=world
120
$ bzr config -d tree hello
239
$ bzr config -d tree --all hello
174
295
def test_branch_config_default(self):
175
296
script.run_script(self, '''\
176
$ bzr config -d tree --remove file
177
$ bzr config -d tree file
297
$ bzr config -d tree --scope locations --remove file
298
$ bzr config -d tree --all file
190
311
def test_branch_config_forcing_branch(self):
191
312
script.run_script(self, '''\
192
313
$ bzr config -d tree --scope branch --remove file
193
$ bzr config -d tree file
314
$ bzr config -d tree --all file
199
321
script.run_script(self, '''\
200
$ bzr config -d tree --remove file
201
$ bzr config -d tree file
322
$ bzr config -d tree --scope locations --remove file
323
$ bzr config -d tree --all file
329
class TestSmartServerConfig(tests.TestCaseWithTransport):
331
def test_simple_branch_config(self):
332
self.setup_smart_server_with_call_log()
333
t = self.make_branch_and_tree('branch')
334
self.reset_smart_call_log()
335
out, err = self.run_bzr(['config', '-d', self.get_url('branch')])
336
# This figure represent the amount of work to perform this use case. It
337
# is entirely ok to reduce this number if a test fails due to rpc_count
338
# being too low. If rpc_count increases, more network roundtrips have
339
# become necessary for this use case. Please do not adjust this number
340
# upwards without agreement from bzr's network support maintainers.
341
self.assertLength(5, self.hpss_calls)
342
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)