~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-18 04:55:00 UTC
  • mfrom: (5784.2.1 754188-apport-test)
  • Revision ID: pqm@pqm.ubuntu.com-20110418045500-ce6lkgyiq7f47q43
(mbp) Rewrite test_report_bug_legacy away from using doctest (see bug
 764188) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
class TestWithoutConfig(tests.TestCaseWithTransport):
33
33
 
34
 
    def test_no_config(self):
 
34
    def test_config_all(self):
35
35
        out, err = self.run_bzr(['config'])
36
36
        self.assertEquals('', out)
37
37
        self.assertEquals('', err)
38
38
 
39
 
    def test_all_variables_no_config(self):
40
 
        out, err = self.run_bzr(['config', '*'])
41
 
        self.assertEquals('', out)
42
 
        self.assertEquals('', err)
 
39
    def test_remove_unknown_option(self):
 
40
        self.run_bzr_error(['The "file" configuration option does not exist',],
 
41
                           ['config', '--remove', 'file'])
 
42
 
 
43
    def test_all_remove_exclusive(self):
 
44
        self.run_bzr_error(['--all and --remove are mutually exclusive.',],
 
45
                           ['config', '--remove', '--all'])
 
46
 
 
47
    def test_all_set_exclusive(self):
 
48
        self.run_bzr_error(['Only one option can be set.',],
 
49
                           ['config', '--all', 'hello=world'])
 
50
 
 
51
    def test_remove_no_option(self):
 
52
        self.run_bzr_error(['--remove expects an option to remove.',],
 
53
                           ['config', '--remove'])
43
54
 
44
55
    def test_unknown_option(self):
45
56
        self.run_bzr_error(['The "file" configuration option does not exist',],
46
 
                           ['config', '--remove', 'file'])
 
57
                           ['config', 'file'])
 
58
 
 
59
    def test_unexpected_regexp(self):
 
60
        self.run_bzr_error(
 
61
            ['The "\*file" configuration option does not exist',],
 
62
            ['config', '*file'])
 
63
 
 
64
    def test_wrong_regexp(self):
 
65
        self.run_bzr_error(
 
66
            ['Invalid pattern\(s\) found. "\*file" nothing to repeat',],
 
67
            ['config', '--all', '*file'])
 
68
 
 
69
 
47
70
 
48
71
class TestConfigDisplay(tests.TestCaseWithTransport):
49
72
 
51
74
        super(TestConfigDisplay, self).setUp()
52
75
        _t_config.create_configs(self)
53
76
 
 
77
    def test_multiline_all_values(self):
 
78
        self.bazaar_config.set_user_option('multiline', '1\n2\n')
 
79
        # Fallout from bug 710410, the triple quotes have been toggled
 
80
        script.run_script(self, '''\
 
81
            $ bzr config -d tree
 
82
            bazaar:
 
83
              multiline = """1
 
84
            2
 
85
            """
 
86
            ''')
 
87
 
 
88
    def test_multiline_value_only(self):
 
89
        self.bazaar_config.set_user_option('multiline', '1\n2\n')
 
90
        # Fallout from bug 710410, the triple quotes have been toggled
 
91
        script.run_script(self, '''\
 
92
            $ bzr config -d tree multiline
 
93
            """1
 
94
            2
 
95
            """
 
96
            ''')
 
97
 
 
98
    def test_list_all_values(self):
 
99
        self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
 
100
        script.run_script(self, '''\
 
101
            $ bzr config -d tree
 
102
            bazaar:
 
103
              list = 1, a, "with, a comma"
 
104
            ''')
 
105
 
 
106
    def test_list_value_only(self):
 
107
        self.bazaar_config.set_user_option('list', [1, 'a', 'with, a comma'])
 
108
        script.run_script(self, '''\
 
109
            $ bzr config -d tree list
 
110
            1, a, "with, a comma"
 
111
            ''')
 
112
 
54
113
    def test_bazaar_config(self):
55
114
        self.bazaar_config.set_user_option('hello', 'world')
56
115
        script.run_script(self, '''\
65
124
        script.run_script(self, '''\
66
125
            $ bzr config -d tree
67
126
            locations:
 
127
              [.../tree]
68
128
              hello = world
69
129
            branch:
70
130
              hello = you
79
139
              hello = world
80
140
            ''')
81
141
 
 
142
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
 
143
 
 
144
    def test_location_with_policy(self):
 
145
        # LocationConfig is the only one dealing with policies so far.
 
146
        self.make_branch_and_tree('tree')
 
147
        config_text = """\
 
148
[%(dir)s]
 
149
url = dir
 
150
url:policy = appendpath
 
151
[%(dir)s/tree]
 
152
url = tree
 
153
""" % {'dir': self.test_dir}
 
154
        # We don't use the config directly so we save it to disk
 
155
        config.LocationConfig.from_string(config_text, 'tree', save=True)
 
156
        # policies are displayed with their options since they are part of
 
157
        # their definition, likewise the path is not appended, we are just
 
158
        # presenting the relevant portions of the config files
 
159
        script.run_script(self, '''\
 
160
            $ bzr config -d tree --all url
 
161
            locations:
 
162
              [.../work/tree]
 
163
              url = tree
 
164
              [.../work]
 
165
              url = dir
 
166
              url:policy = appendpath
 
167
            ''')
 
168
 
 
169
 
 
170
class TestConfigActive(tests.TestCaseWithTransport):
 
171
 
 
172
    def setUp(self):
 
173
        super(TestConfigActive, self).setUp()
 
174
        _t_config.create_configs_with_file_option(self)
 
175
 
 
176
    def test_active_in_locations(self):
 
177
        script.run_script(self, '''\
 
178
            $ bzr config -d tree file
 
179
            locations
 
180
            ''')
 
181
 
 
182
    def test_active_in_bazaar(self):
 
183
        script.run_script(self, '''\
 
184
            $ bzr config -d tree --scope bazaar file
 
185
            bazaar
 
186
            ''')
 
187
 
 
188
    def test_active_in_branch(self):
 
189
        # We need to delete the locations definition that overrides the branch
 
190
        # one
 
191
        script.run_script(self, '''\
 
192
            $ bzr config -d tree --remove file
 
193
            $ bzr config -d tree file
 
194
            branch
 
195
            ''')
 
196
 
82
197
 
83
198
class TestConfigSetOption(tests.TestCaseWithTransport):
84
199
 
93
208
    def test_bazaar_config_outside_branch(self):
94
209
        script.run_script(self, '''\
95
210
            $ bzr config --scope bazaar hello=world
96
 
            $ bzr config -d tree hello
 
211
            $ bzr config -d tree --all hello
97
212
            bazaar:
98
213
              hello = world
99
214
            ''')
101
216
    def test_bazaar_config_inside_branch(self):
102
217
        script.run_script(self, '''\
103
218
            $ bzr config -d tree --scope bazaar hello=world
104
 
            $ bzr config -d tree hello
 
219
            $ bzr config -d tree --all hello
105
220
            bazaar:
106
221
              hello = world
107
222
            ''')
109
224
    def test_locations_config_inside_branch(self):
110
225
        script.run_script(self, '''\
111
226
            $ bzr config -d tree --scope locations hello=world
112
 
            $ bzr config -d tree hello
 
227
            $ bzr config -d tree --all hello
113
228
            locations:
 
229
              [.../work/tree]
114
230
              hello = world
115
231
            ''')
116
232
 
117
233
    def test_branch_config_default(self):
118
234
        script.run_script(self, '''\
119
235
            $ bzr config -d tree hello=world
120
 
            $ bzr config -d tree hello
 
236
            $ bzr config -d tree --all hello
121
237
            branch:
122
238
              hello = world
123
239
            ''')
125
241
    def test_branch_config_forcing_branch(self):
126
242
        script.run_script(self, '''\
127
243
            $ bzr config -d tree --scope branch hello=world
128
 
            $ bzr config -d tree hello
 
244
            $ bzr config -d tree --all hello
129
245
            branch:
130
246
              hello = world
131
247
            ''')
144
260
    def test_bazaar_config_outside_branch(self):
145
261
        script.run_script(self, '''\
146
262
            $ bzr config --scope bazaar --remove file
147
 
            $ bzr config -d tree file
 
263
            $ bzr config -d tree --all file
148
264
            locations:
 
265
              [.../work/tree]
149
266
              file = locations
150
267
            branch:
151
268
              file = branch
154
271
    def test_bazaar_config_inside_branch(self):
155
272
        script.run_script(self, '''\
156
273
            $ bzr config -d tree --scope bazaar --remove file
157
 
            $ bzr config -d tree file
 
274
            $ bzr config -d tree --all file
158
275
            locations:
 
276
              [.../work/tree]
159
277
              file = locations
160
278
            branch:
161
279
              file = branch
164
282
    def test_locations_config_inside_branch(self):
165
283
        script.run_script(self, '''\
166
284
            $ bzr config -d tree --scope locations --remove file
167
 
            $ bzr config -d tree file
 
285
            $ bzr config -d tree --all file
168
286
            branch:
169
287
              file = branch
170
288
            bazaar:
174
292
    def test_branch_config_default(self):
175
293
        script.run_script(self, '''\
176
294
            $ bzr config -d tree --remove file
177
 
            $ bzr config -d tree file
 
295
            $ bzr config -d tree --all file
178
296
            branch:
179
297
              file = branch
180
298
            bazaar:
182
300
            ''')
183
301
        script.run_script(self, '''\
184
302
            $ bzr config -d tree --remove file
185
 
            $ bzr config -d tree file
 
303
            $ bzr config -d tree --all file
186
304
            bazaar:
187
305
              file = bazaar
188
306
            ''')
190
308
    def test_branch_config_forcing_branch(self):
191
309
        script.run_script(self, '''\
192
310
            $ bzr config -d tree --scope branch --remove file
193
 
            $ bzr config -d tree file
 
311
            $ bzr config -d tree --all file
194
312
            locations:
 
313
              [.../work/tree]
195
314
              file = locations
196
315
            bazaar:
197
316
              file = bazaar
198
317
            ''')
199
318
        script.run_script(self, '''\
200
319
            $ bzr config -d tree --remove file
201
 
            $ bzr config -d tree file
 
320
            $ bzr config -d tree --all file
202
321
            bazaar:
203
322
              file = bazaar
204
323
            ''')