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):
98
def test_list_all_values(self):
98
def test_list_value_all(self):
99
config.option_registry.register(config.ListOption('list'))
100
self.addCleanup(config.option_registry.remove, 'list')
99
101
self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
100
102
script.run_script(self, '''\
101
103
$ bzr config -d tree
103
106
list = 1, a, "with, a comma"
106
def test_list_value_only(self):
109
def test_list_value_one(self):
110
config.option_registry.register(config.ListOption('list'))
111
self.addCleanup(config.option_registry.remove, 'list')
107
112
self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
108
113
script.run_script(self, '''\
109
114
$ bzr config -d tree list
110
115
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
113
136
def test_bazaar_config(self):
114
137
self.bazaar_config.set_user_option('hello', 'world')
115
138
script.run_script(self, '''\
116
139
$ bzr config -d tree
136
160
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
142
179
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
189
226
# We need to delete the locations definition that overrides the branch
191
228
script.run_script(self, '''\
192
$ bzr config -d tree --remove file
229
$ bzr config -d tree --scope locations --remove file
193
230
$ bzr config -d tree file
292
332
def test_branch_config_default(self):
293
333
script.run_script(self, '''\
294
$ bzr config -d tree --remove file
334
$ bzr config -d tree --scope locations --remove file
295
335
$ bzr config -d tree --all file
301
342
script.run_script(self, '''\
302
343
$ bzr config -d tree --remove file
303
344
$ bzr config -d tree --all file
318
361
script.run_script(self, '''\
319
$ bzr config -d tree --remove file
362
$ bzr config -d tree --scope locations --remove file
320
363
$ 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)