/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2017-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    script,
26
26
    test_config as _t_config,
27
27
    )
 
28
from ..matchers import ContainsNoVfsCalls
28
29
 
29
30
 
30
31
class TestWithoutConfig(tests.TestCaseWithTransport):
35
36
        self.assertEqual('', err)
36
37
 
37
38
    def test_remove_unknown_option(self):
38
 
        self.run_bzr_error(['The "file" configuration option does not exist', ],
 
39
        self.run_bzr_error(['The "file" configuration option does not exist',],
39
40
                           ['config', '--remove', 'file'])
40
41
 
41
42
    def test_all_remove_exclusive(self):
42
 
        self.run_bzr_error(['--all and --remove are mutually exclusive.', ],
 
43
        self.run_bzr_error(['--all and --remove are mutually exclusive.',],
43
44
                           ['config', '--remove', '--all'])
44
45
 
45
46
    def test_all_set_exclusive(self):
46
 
        self.run_bzr_error(['Only one option can be set.', ],
 
47
        self.run_bzr_error(['Only one option can be set.',],
47
48
                           ['config', '--all', 'hello=world'])
48
49
 
49
50
    def test_remove_no_option(self):
50
 
        self.run_bzr_error(['--remove expects an option to remove.', ],
 
51
        self.run_bzr_error(['--remove expects an option to remove.',],
51
52
                           ['config', '--remove'])
52
53
 
53
54
    def test_unknown_option(self):
54
 
        self.run_bzr_error(['The "file" configuration option does not exist', ],
 
55
        self.run_bzr_error(['The "file" configuration option does not exist',],
55
56
                           ['config', 'file'])
56
57
 
57
58
    def test_unexpected_regexp(self):
58
59
        self.run_bzr_error(
59
 
            ['The "\\*file" configuration option does not exist', ],
 
60
            ['The "\*file" configuration option does not exist',],
60
61
            ['config', '*file'])
61
62
 
62
63
    def test_wrong_regexp(self):
63
64
        self.run_bzr_error(
64
 
            ['Invalid pattern\\(s\\) found. "\\*file" nothing to repeat', ],
 
65
            ['Invalid pattern\(s\) found. "\*file" nothing to repeat',],
65
66
            ['config', '--all', '*file'])
66
67
 
67
68
 
 
69
 
68
70
class TestConfigDisplay(tests.TestCaseWithTransport):
69
71
 
70
72
    def setUp(self):
72
74
        _t_config.create_configs(self)
73
75
 
74
76
    def test_multiline_all_values(self):
75
 
        self.breezy_config.set_user_option('multiline', '1\n2\n')
 
77
        self.bazaar_config.set_user_option('multiline', '1\n2\n')
76
78
        # Fallout from bug 710410, the triple quotes have been toggled
77
79
        script.run_script(self, '''\
78
80
            $ brz config -d tree
79
 
            breezy:
 
81
            bazaar:
80
82
              [DEFAULT]
81
83
              multiline = """1
82
84
            2
84
86
            ''')
85
87
 
86
88
    def test_multiline_value_only(self):
87
 
        self.breezy_config.set_user_option('multiline', '1\n2\n')
 
89
        self.bazaar_config.set_user_option('multiline', '1\n2\n')
88
90
        # Fallout from bug 710410, the triple quotes have been toggled
89
91
        script.run_script(self, '''\
90
92
            $ brz config -d tree multiline
96
98
    def test_list_value_all(self):
97
99
        config.option_registry.register(config.ListOption('list'))
98
100
        self.addCleanup(config.option_registry.remove, 'list')
99
 
        self.breezy_config.set_user_option('list', [1, 'a', 'with, a comma'])
 
101
        self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
100
102
        script.run_script(self, '''\
101
103
            $ brz config -d tree
102
 
            breezy:
 
104
            bazaar:
103
105
              [DEFAULT]
104
106
              list = 1, a, "with, a comma"
105
107
            ''')
107
109
    def test_list_value_one(self):
108
110
        config.option_registry.register(config.ListOption('list'))
109
111
        self.addCleanup(config.option_registry.remove, 'list')
110
 
        self.breezy_config.set_user_option('list', [1, 'a', 'with, a comma'])
 
112
        self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
111
113
        script.run_script(self, '''\
112
114
            $ brz config -d tree list
113
115
            1, a, "with, a comma"
114
116
            ''')
115
117
 
116
118
    def test_registry_value_all(self):
117
 
        self.breezy_config.set_user_option('transform.orphan_policy',
 
119
        self.bazaar_config.set_user_option('bzr.transform.orphan_policy',
118
120
                                           u'move')
119
121
        script.run_script(self, '''\
120
122
            $ brz config -d tree
121
 
            breezy:
 
123
            bazaar:
122
124
              [DEFAULT]
123
 
              transform.orphan_policy = move
 
125
              bzr.transform.orphan_policy = move
124
126
            ''')
125
127
 
126
128
    def test_registry_value_one(self):
127
 
        self.breezy_config.set_user_option('transform.orphan_policy',
 
129
        self.bazaar_config.set_user_option('bzr.transform.orphan_policy',
128
130
                                           u'move')
129
131
        script.run_script(self, '''\
130
 
            $ brz config -d tree transform.orphan_policy
 
132
            $ brz config -d tree bzr.transform.orphan_policy
131
133
            move
132
134
            ''')
133
135
 
134
 
    def test_breezy_config(self):
135
 
        self.breezy_config.set_user_option('hello', 'world')
 
136
    def test_bazaar_config(self):
 
137
        self.bazaar_config.set_user_option('hello', 'world')
136
138
        script.run_script(self, '''\
137
139
            $ brz config -d tree
138
 
            breezy:
 
140
            bazaar:
139
141
              [DEFAULT]
140
142
              hello = world
141
143
            ''')
153
155
            ''')
154
156
 
155
157
    def test_locations_config_outside_branch(self):
156
 
        self.breezy_config.set_user_option('hello', 'world')
 
158
        self.bazaar_config.set_user_option('hello', 'world')
157
159
        self.locations_config.set_user_option('hello', 'world')
158
160
        script.run_script(self, '''\
159
161
            $ brz config
160
 
            breezy:
 
162
            bazaar:
161
163
              [DEFAULT]
162
164
              hello = world
163
165
            ''')
164
166
 
165
167
    def test_cmd_line(self):
166
 
        self.breezy_config.set_user_option('hello', 'world')
 
168
        self.bazaar_config.set_user_option('hello', 'world')
167
169
        script.run_script(self, '''\
168
170
            $ brz config -Ohello=bzr
169
171
            cmdline:
170
172
              hello = bzr
171
 
            breezy:
 
173
            bazaar:
172
174
              [DEFAULT]
173
175
              hello = world
174
176
            ''')
214
216
            locations
215
217
            ''')
216
218
 
217
 
    def test_active_in_breezy(self):
 
219
    def test_active_in_bazaar(self):
218
220
        script.run_script(self, '''\
219
 
            $ brz config -d tree --scope breezy file
220
 
            breezy
 
221
            $ brz config -d tree --scope bazaar file
 
222
            bazaar
221
223
            ''')
222
224
 
223
225
    def test_active_in_branch(self):
240
242
        self.run_bzr_error(['The "moon" configuration does not exist'],
241
243
                           ['config', '--scope', 'moon', 'hello=world'])
242
244
 
243
 
    def test_breezy_config_outside_branch(self):
 
245
    def test_bazaar_config_outside_branch(self):
244
246
        script.run_script(self, '''\
245
 
            $ brz config --scope breezy hello=world
 
247
            $ brz config --scope bazaar hello=world
246
248
            $ brz config -d tree --all hello
247
 
            breezy:
 
249
            bazaar:
248
250
              [DEFAULT]
249
251
              hello = world
250
252
            ''')
251
253
 
252
 
    def test_breezy_config_inside_branch(self):
 
254
    def test_bazaar_config_inside_branch(self):
253
255
        script.run_script(self, '''\
254
 
            $ brz config -d tree --scope breezy hello=world
 
256
            $ brz config -d tree --scope bazaar hello=world
255
257
            $ brz config -d tree --all hello
256
 
            breezy:
 
258
            bazaar:
257
259
              [DEFAULT]
258
260
              hello = world
259
261
            ''')
294
296
        self.run_bzr_error(['The "moon" configuration does not exist'],
295
297
                           ['config', '--scope', 'moon', '--remove', 'file'])
296
298
 
297
 
    def test_breezy_config_outside_branch(self):
 
299
    def test_bazaar_config_outside_branch(self):
298
300
        script.run_script(self, '''\
299
 
            $ brz config --scope breezy --remove file
 
301
            $ brz config --scope bazaar --remove file
300
302
            $ brz config -d tree --all file
301
303
            locations:
302
304
              [.../work/tree]
305
307
              file = branch
306
308
            ''')
307
309
 
308
 
    def test_breezy_config_inside_branch(self):
 
310
    def test_bazaar_config_inside_branch(self):
309
311
        script.run_script(self, '''\
310
 
            $ brz config -d tree --scope breezy --remove file
 
312
            $ brz config -d tree --scope bazaar --remove file
311
313
            $ brz config -d tree --all file
312
314
            locations:
313
315
              [.../work/tree]
322
324
            $ brz config -d tree --all file
323
325
            branch:
324
326
              file = branch
325
 
            breezy:
 
327
            bazaar:
326
328
              [DEFAULT]
327
 
              file = breezy
 
329
              file = bazaar
328
330
            ''')
329
331
 
330
332
    def test_branch_config_default(self):
333
335
            $ brz config -d tree --all file
334
336
            branch:
335
337
              file = branch
336
 
            breezy:
 
338
            bazaar:
337
339
              [DEFAULT]
338
 
              file = breezy
 
340
              file = bazaar
339
341
            ''')
340
342
        script.run_script(self, '''\
341
343
            $ brz config -d tree --remove file
342
344
            $ brz config -d tree --all file
343
 
            breezy:
 
345
            bazaar:
344
346
              [DEFAULT]
345
 
              file = breezy
 
347
              file = bazaar
346
348
            ''')
347
349
 
348
350
    def test_branch_config_forcing_branch(self):
352
354
            locations:
353
355
              [.../work/tree]
354
356
              file = locations
355
 
            breezy:
 
357
            bazaar:
356
358
              [DEFAULT]
357
 
              file = breezy
 
359
              file = bazaar
358
360
            ''')
359
361
        script.run_script(self, '''\
360
362
            $ brz config -d tree --scope locations --remove file
361
363
            $ brz config -d tree --all file
362
 
            breezy:
 
364
            bazaar:
363
365
              [DEFAULT]
364
 
              file = breezy
 
366
              file = bazaar
365
367
            ''')
366
368
 
367
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
 
368
387
class TestConfigDirectory(tests.TestCaseWithTransport):
369
388
 
370
389
    def test_parent_alias(self):
371
390
        t = self.make_branch_and_tree('base')
372
391
        t.branch.get_config_stack().set('test', 'base')
373
 
        clone = t.branch.controldir.sprout('clone').open_branch()
 
392
        clone = t.branch.bzrdir.sprout('clone').open_branch()
374
393
        clone.get_config_stack().set('test', 'clone')
375
394
        out, err = self.run_bzr(['config', '-d', ':parent', 'test'],
376
395
                                working_dir='clone')