~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2011-09-30 01:21:33 UTC
  • mfrom: (6178.1.3 557886-update-file)
  • Revision ID: pqm@pqm.ubuntu.com-20110930012133-ey9vb4tsl104kos5
(mbp) 'bzr update PATH' makes it clear you can't update a single file
 (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010, 2011, 2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
 
18
18
"""Black-box tests for bzr config."""
19
19
 
 
20
import os
 
21
 
20
22
from bzrlib import (
21
23
    config,
 
24
    errors,
22
25
    tests,
23
26
    )
24
27
from bzrlib.tests import (
25
28
    script,
26
29
    test_config as _t_config,
27
30
    )
28
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
29
 
 
30
31
 
31
32
class TestWithoutConfig(tests.TestCaseWithTransport):
32
33
 
33
34
    def test_config_all(self):
34
35
        out, err = self.run_bzr(['config'])
35
 
        self.assertEqual('', out)
36
 
        self.assertEqual('', err)
 
36
        self.assertEquals('', out)
 
37
        self.assertEquals('', err)
37
38
 
38
39
    def test_remove_unknown_option(self):
39
40
        self.run_bzr_error(['The "file" configuration option does not exist',],
79
80
        script.run_script(self, '''\
80
81
            $ bzr config -d tree
81
82
            bazaar:
82
 
              [DEFAULT]
83
83
              multiline = """1
84
84
            2
85
85
            """
95
95
            """
96
96
            ''')
97
97
 
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
104
102
            bazaar:
105
 
              [DEFAULT]
106
103
              list = 1, a, "with, a comma"
107
104
            ''')
108
105
 
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"
116
111
            ''')
117
112
 
118
 
    def test_registry_value_all(self):
119
 
        self.bazaar_config.set_user_option('bzr.transform.orphan_policy',
120
 
                                           u'move')
121
 
        script.run_script(self, '''\
122
 
            $ bzr config -d tree
123
 
            bazaar:
124
 
              [DEFAULT]
125
 
              bzr.transform.orphan_policy = move
126
 
            ''')
127
 
 
128
 
    def test_registry_value_one(self):
129
 
        self.bazaar_config.set_user_option('bzr.transform.orphan_policy',
130
 
                                           u'move')
131
 
        script.run_script(self, '''\
132
 
            $ bzr config -d tree bzr.transform.orphan_policy
133
 
            move
134
 
            ''')
135
 
 
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
140
117
            bazaar:
141
 
              [DEFAULT]
142
118
              hello = world
143
119
            ''')
144
120
 
160
136
        script.run_script(self, '''\
161
137
            $ bzr config
162
138
            bazaar:
163
 
              [DEFAULT]
164
 
              hello = world
165
 
            ''')
166
 
 
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
171
 
            cmdline:
172
 
              hello = bzr
173
 
            bazaar:
174
 
              [DEFAULT]
175
 
              hello = world
176
 
            ''')
177
 
 
 
139
              hello = world
 
140
            ''')
178
141
 
179
142
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
180
143
 
226
189
        # We need to delete the locations definition that overrides the branch
227
190
        # one
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
231
194
            branch
232
195
            ''')
247
210
            $ bzr config --scope bazaar hello=world
248
211
            $ bzr config -d tree --all hello
249
212
            bazaar:
250
 
              [DEFAULT]
251
213
              hello = world
252
214
            ''')
253
215
 
256
218
            $ bzr config -d tree --scope bazaar hello=world
257
219
            $ bzr config -d tree --all hello
258
220
            bazaar:
259
 
              [DEFAULT]
260
221
              hello = world
261
222
            ''')
262
223
 
325
286
            branch:
326
287
              file = branch
327
288
            bazaar:
328
 
              [DEFAULT]
329
289
              file = bazaar
330
290
            ''')
331
291
 
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
336
296
            branch:
337
297
              file = branch
338
298
            bazaar:
339
 
              [DEFAULT]
340
299
              file = bazaar
341
300
            ''')
342
301
        script.run_script(self, '''\
343
302
            $ bzr config -d tree --remove file
344
303
            $ bzr config -d tree --all file
345
304
            bazaar:
346
 
              [DEFAULT]
347
305
              file = bazaar
348
306
            ''')
349
307
 
355
313
              [.../work/tree]
356
314
              file = locations
357
315
            bazaar:
358
 
              [DEFAULT]
359
316
              file = bazaar
360
317
            ''')
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
364
321
            bazaar:
365
 
              [DEFAULT]
366
322
              file = bazaar
367
323
            ''')
368
 
 
369
 
 
370
 
class TestSmartServerConfig(tests.TestCaseWithTransport):
371
 
 
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)
385
 
 
386
 
 
387
 
class TestConfigDirectory(tests.TestCaseWithTransport):
388
 
 
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'],
395
 
                                working_dir='clone')
396
 
        self.assertEqual('base\n', out)