~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(gz) Remove bzrlib/util/elementtree/ package (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Black-box tests for bzr config."""
19
19
 
20
 
import os
21
 
 
22
20
from bzrlib import (
23
21
    config,
24
 
    errors,
25
22
    tests,
26
23
    )
27
24
from bzrlib.tests import (
28
25
    script,
29
26
    test_config as _t_config,
30
27
    )
 
28
from bzrlib.tests.matchers import ContainsNoVfsCalls
 
29
 
31
30
 
32
31
class TestWithoutConfig(tests.TestCaseWithTransport):
33
32
 
80
79
        script.run_script(self, '''\
81
80
            $ bzr config -d tree
82
81
            bazaar:
 
82
              [DEFAULT]
83
83
              multiline = """1
84
84
            2
85
85
            """
96
96
            ''')
97
97
 
98
98
    def test_list_all_values(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
102
104
            bazaar:
 
105
              [DEFAULT]
103
106
              list = 1, a, "with, a comma"
104
107
            ''')
105
108
 
106
109
    def test_list_value_only(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
115
120
        script.run_script(self, '''\
116
121
            $ bzr config -d tree
117
122
            bazaar:
 
123
              [DEFAULT]
118
124
              hello = world
119
125
            ''')
120
126
 
136
142
        script.run_script(self, '''\
137
143
            $ bzr config
138
144
            bazaar:
139
 
              hello = world
140
 
            ''')
 
145
              [DEFAULT]
 
146
              hello = world
 
147
            ''')
 
148
 
 
149
    def test_cmd_line(self):
 
150
        self.bazaar_config.set_user_option('hello', 'world')
 
151
        script.run_script(self, '''\
 
152
            $ bzr config -Ohello=bzr
 
153
            cmdline:
 
154
              hello = bzr
 
155
            bazaar:
 
156
              [DEFAULT]
 
157
              hello = world
 
158
            ''')
 
159
 
141
160
 
142
161
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
143
162
 
189
208
        # We need to delete the locations definition that overrides the branch
190
209
        # one
191
210
        script.run_script(self, '''\
192
 
            $ bzr config -d tree --remove file
 
211
            $ bzr config -d tree --scope locations --remove file
193
212
            $ bzr config -d tree file
194
213
            branch
195
214
            ''')
210
229
            $ bzr config --scope bazaar hello=world
211
230
            $ bzr config -d tree --all hello
212
231
            bazaar:
 
232
              [DEFAULT]
213
233
              hello = world
214
234
            ''')
215
235
 
218
238
            $ bzr config -d tree --scope bazaar hello=world
219
239
            $ bzr config -d tree --all hello
220
240
            bazaar:
 
241
              [DEFAULT]
221
242
              hello = world
222
243
            ''')
223
244
 
286
307
            branch:
287
308
              file = branch
288
309
            bazaar:
 
310
              [DEFAULT]
289
311
              file = bazaar
290
312
            ''')
291
313
 
292
314
    def test_branch_config_default(self):
293
315
        script.run_script(self, '''\
294
 
            $ bzr config -d tree --remove file
 
316
            $ bzr config -d tree --scope locations --remove file
295
317
            $ bzr config -d tree --all file
296
318
            branch:
297
319
              file = branch
298
320
            bazaar:
 
321
              [DEFAULT]
299
322
              file = bazaar
300
323
            ''')
301
324
        script.run_script(self, '''\
302
325
            $ bzr config -d tree --remove file
303
326
            $ bzr config -d tree --all file
304
327
            bazaar:
 
328
              [DEFAULT]
305
329
              file = bazaar
306
330
            ''')
307
331
 
313
337
              [.../work/tree]
314
338
              file = locations
315
339
            bazaar:
 
340
              [DEFAULT]
316
341
              file = bazaar
317
342
            ''')
318
343
        script.run_script(self, '''\
319
 
            $ bzr config -d tree --remove file
 
344
            $ bzr config -d tree --scope locations --remove file
320
345
            $ bzr config -d tree --all file
321
346
            bazaar:
 
347
              [DEFAULT]
322
348
              file = bazaar
323
349
            ''')
 
350
 
 
351
 
 
352
class TestSmartServerConfig(tests.TestCaseWithTransport):
 
353
 
 
354
    def test_simple_branch_config(self):
 
355
        self.setup_smart_server_with_call_log()
 
356
        t = self.make_branch_and_tree('branch')
 
357
        self.reset_smart_call_log()
 
358
        out, err = self.run_bzr(['config', '-d', self.get_url('branch')])
 
359
        # This figure represent the amount of work to perform this use case. It
 
360
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
361
        # being too low. If rpc_count increases, more network roundtrips have
 
362
        # become necessary for this use case. Please do not adjust this number
 
363
        # upwards without agreement from bzr's network support maintainers.
 
364
        self.assertLength(5, self.hpss_calls)
 
365
        self.assertLength(1, self.hpss_connections)
 
366
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)