18
18
"""Black-box tests for bzr config."""
20
22
from bzrlib import (
24
27
from bzrlib.tests import (
26
29
test_config as _t_config,
28
from bzrlib.tests.matchers import ContainsNoVfsCalls
31
32
class TestWithoutConfig(tests.TestCaseWithTransport):
98
def test_list_value_all(self):
99
config.option_registry.register(config.ListOption('list'))
100
self.addCleanup(config.option_registry.remove, 'list')
98
def test_list_all_values(self):
101
99
self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
102
100
script.run_script(self, '''\
103
101
$ bzr config -d tree
106
103
list = 1, a, "with, a comma"
109
def test_list_value_one(self):
110
config.option_registry.register(config.ListOption('list'))
111
self.addCleanup(config.option_registry.remove, 'list')
106
def test_list_value_only(self):
112
107
self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
113
108
script.run_script(self, '''\
114
109
$ bzr config -d tree list
115
110
1, a, "with, a comma"
118
def test_registry_value_all(self):
119
self.bazaar_config.set_user_option('bzr.transform.orphan_policy',
121
script.run_script(self, '''\
125
bzr.transform.orphan_policy = move
128
def test_registry_value_one(self):
129
self.bazaar_config.set_user_option('bzr.transform.orphan_policy',
131
script.run_script(self, '''\
132
$ bzr config -d tree bzr.transform.orphan_policy
136
113
def test_bazaar_config(self):
137
114
self.bazaar_config.set_user_option('hello', 'world')
138
115
script.run_script(self, '''\
139
116
$ bzr config -d tree
160
136
script.run_script(self, '''\
167
def test_cmd_line(self):
168
self.bazaar_config.set_user_option('hello', 'world')
169
script.run_script(self, '''\
170
$ bzr config -Ohello=bzr
179
142
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
226
189
# We need to delete the locations definition that overrides the branch
228
191
script.run_script(self, '''\
229
$ bzr config -d tree --scope locations --remove file
192
$ bzr config -d tree --remove file
230
193
$ bzr config -d tree file
332
292
def test_branch_config_default(self):
333
293
script.run_script(self, '''\
334
$ bzr config -d tree --scope locations --remove file
294
$ bzr config -d tree --remove file
335
295
$ bzr config -d tree --all file
342
301
script.run_script(self, '''\
343
302
$ bzr config -d tree --remove file
344
303
$ bzr config -d tree --all file
361
318
script.run_script(self, '''\
362
$ bzr config -d tree --scope locations --remove file
319
$ bzr config -d tree --remove file
363
320
$ bzr config -d tree --all file
370
class TestSmartServerConfig(tests.TestCaseWithTransport):
372
def test_simple_branch_config(self):
373
self.setup_smart_server_with_call_log()
374
t = self.make_branch_and_tree('branch')
375
self.reset_smart_call_log()
376
out, err = self.run_bzr(['config', '-d', self.get_url('branch')])
377
# This figure represent the amount of work to perform this use case. It
378
# is entirely ok to reduce this number if a test fails due to rpc_count
379
# being too low. If rpc_count increases, more network roundtrips have
380
# become necessary for this use case. Please do not adjust this number
381
# upwards without agreement from bzr's network support maintainers.
382
self.assertLength(5, self.hpss_calls)
383
self.assertLength(1, self.hpss_connections)
384
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
387
class TestConfigDirectory(tests.TestCaseWithTransport):
389
def test_parent_alias(self):
390
t = self.make_branch_and_tree('base')
391
t.branch.get_config_stack().set('test', 'base')
392
clone = t.branch.bzrdir.sprout('clone').open_branch()
393
clone.get_config_stack().set('test', 'clone')
394
out, err = self.run_bzr(['config', '-d', ':parent', 'test'],
396
self.assertEquals('base\n', out)