/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2010, 2011, 2012, 2016 Canonical Ltd
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17
6622.1.29 by Jelmer Vernooij
Fix some more tests.
18
"""Black-box tests for brz config."""
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
19
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
20
from ... import (
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
21
    config,
22
    tests,
23
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
24
from .. import (
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
25
    script,
26
    test_config as _t_config,
27
    )
6352.2.2 by Jelmer Vernooij
Use new NoVfsCalls matcher in blackbox tests.
28
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
29
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
30
class TestWithoutConfig(tests.TestCaseWithTransport):
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
31
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
32
    def test_config_all(self):
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
33
        out, err = self.run_bzr(['config'])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
34
        self.assertEqual('', out)
35
        self.assertEqual('', err)
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
36
5506.2.2 by Vincent Ladeuil
Raise an error if the option doesn't exist and --active is used.
37
    def test_remove_unknown_option(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
38
        self.run_bzr_error(['The "file" configuration option does not exist', ],
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
39
                           ['config', '--remove', 'file'])
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
40
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
41
    def test_all_remove_exclusive(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
42
        self.run_bzr_error(['--all and --remove are mutually exclusive.', ],
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
43
                           ['config', '--remove', '--all'])
44
45
    def test_all_set_exclusive(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
46
        self.run_bzr_error(['Only one option can be set.', ],
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
47
                           ['config', '--all', 'hello=world'])
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
48
5506.2.2 by Vincent Ladeuil
Raise an error if the option doesn't exist and --active is used.
49
    def test_remove_no_option(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
50
        self.run_bzr_error(['--remove expects an option to remove.', ],
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
51
                           ['config', '--remove'])
52
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
53
    def test_unknown_option(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
54
        self.run_bzr_error(['The "file" configuration option does not exist', ],
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
55
                           ['config', 'file'])
56
57
    def test_unexpected_regexp(self):
58
        self.run_bzr_error(
7143.15.2 by Jelmer Vernooij
Run autopep8.
59
            ['The "\\*file" configuration option does not exist', ],
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
60
            ['config', '*file'])
61
62
    def test_wrong_regexp(self):
63
        self.run_bzr_error(
7143.15.2 by Jelmer Vernooij
Run autopep8.
64
            ['Invalid pattern\\(s\\) found. "\\*file" nothing to repeat', ],
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
65
            ['config', '--all', '*file'])
66
5506.2.2 by Vincent Ladeuil
Raise an error if the option doesn't exist and --active is used.
67
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
68
class TestConfigDisplay(tests.TestCaseWithTransport):
69
70
    def setUp(self):
71
        super(TestConfigDisplay, self).setUp()
72
        _t_config.create_configs(self)
73
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
74
    def test_multiline_all_values(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
75
        self.breezy_config.set_user_option('multiline', '1\n2\n')
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
76
        # Fallout from bug 710410, the triple quotes have been toggled
77
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
78
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
79
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
80
              [DEFAULT]
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
81
              multiline = """1
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
82
            2
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
83
            """
84
            ''')
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
85
86
    def test_multiline_value_only(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
87
        self.breezy_config.set_user_option('multiline', '1\n2\n')
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
88
        # Fallout from bug 710410, the triple quotes have been toggled
89
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
90
            $ brz config -d tree multiline
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
91
            """1
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
92
            2
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
93
            """
94
            ''')
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
95
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
96
    def test_list_value_all(self):
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
97
        config.option_registry.register(config.ListOption('list'))
98
        self.addCleanup(config.option_registry.remove, 'list')
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
99
        self.breezy_config.set_user_option('list', [1, 'a', 'with, a comma'])
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
100
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
101
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
102
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
103
              [DEFAULT]
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
104
              list = 1, a, "with, a comma"
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
105
            ''')
106
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
107
    def test_list_value_one(self):
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
108
        config.option_registry.register(config.ListOption('list'))
109
        self.addCleanup(config.option_registry.remove, 'list')
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
110
        self.breezy_config.set_user_option('list', [1, 'a', 'with, a comma'])
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
111
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
112
            $ brz config -d tree list
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
113
            1, a, "with, a comma"
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
114
            ''')
115
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
116
    def test_registry_value_all(self):
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
117
        self.breezy_config.set_user_option('transform.orphan_policy',
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
118
                                           u'move')
119
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
120
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
121
            breezy:
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
122
              [DEFAULT]
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
123
              transform.orphan_policy = move
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
124
            ''')
125
126
    def test_registry_value_one(self):
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
127
        self.breezy_config.set_user_option('transform.orphan_policy',
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
128
                                           u'move')
129
        script.run_script(self, '''\
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
130
            $ brz config -d tree transform.orphan_policy
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
131
            move
132
            ''')
133
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
134
    def test_breezy_config(self):
135
        self.breezy_config.set_user_option('hello', 'world')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
136
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
137
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
138
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
139
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
140
              hello = world
141
            ''')
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
142
143
    def test_locations_config_for_branch(self):
144
        self.locations_config.set_user_option('hello', 'world')
145
        self.branch_config.set_user_option('hello', 'you')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
146
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
147
            $ brz config -d tree
5447.4.20 by Vincent Ladeuil
Indent inplace files.
148
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
149
              [.../tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
150
              hello = world
151
            branch:
152
              hello = you
153
            ''')
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
154
155
    def test_locations_config_outside_branch(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
156
        self.breezy_config.set_user_option('hello', 'world')
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
157
        self.locations_config.set_user_option('hello', 'world')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
158
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
159
            $ brz config
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
160
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
161
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
162
              hello = world
163
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
164
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
165
    def test_cmd_line(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
166
        self.breezy_config.set_user_option('hello', 'world')
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
167
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
168
            $ brz config -Ohello=bzr
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
169
            cmdline:
170
              hello = bzr
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
171
            breezy:
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
172
              [DEFAULT]
173
              hello = world
174
            ''')
175
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
176
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
177
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
178
179
    def test_location_with_policy(self):
180
        # LocationConfig is the only one dealing with policies so far.
181
        self.make_branch_and_tree('tree')
182
        config_text = """\
183
[%(dir)s]
184
url = dir
185
url:policy = appendpath
186
[%(dir)s/tree]
187
url = tree
188
""" % {'dir': self.test_dir}
189
        # We don't use the config directly so we save it to disk
190
        config.LocationConfig.from_string(config_text, 'tree', save=True)
191
        # policies are displayed with their options since they are part of
192
        # their definition, likewise the path is not appended, we are just
193
        # presenting the relevant portions of the config files
194
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
195
            $ brz config -d tree --all url
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
196
            locations:
197
              [.../work/tree]
198
              url = tree
199
              [.../work]
200
              url = dir
201
              url:policy = appendpath
202
            ''')
203
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
204
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
205
class TestConfigActive(tests.TestCaseWithTransport):
206
207
    def setUp(self):
208
        super(TestConfigActive, self).setUp()
209
        _t_config.create_configs_with_file_option(self)
210
211
    def test_active_in_locations(self):
212
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
213
            $ brz config -d tree file
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
214
            locations
215
            ''')
216
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
217
    def test_active_in_breezy(self):
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
218
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
219
            $ brz config -d tree --scope breezy file
220
            breezy
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
221
            ''')
222
223
    def test_active_in_branch(self):
224
        # We need to delete the locations definition that overrides the branch
225
        # one
226
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
227
            $ brz config -d tree --scope locations --remove file
228
            $ brz config -d tree file
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
229
            branch
230
            ''')
231
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
232
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
233
class TestConfigSetOption(tests.TestCaseWithTransport):
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
234
235
    def setUp(self):
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
236
        super(TestConfigSetOption, self).setUp()
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
237
        _t_config.create_configs(self)
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
238
239
    def test_unknown_config(self):
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
240
        self.run_bzr_error(['The "moon" configuration does not exist'],
5447.4.17 by Vincent Ladeuil
Rename config --force to config --scope.
241
                           ['config', '--scope', 'moon', 'hello=world'])
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
242
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
243
    def test_breezy_config_outside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
244
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
245
            $ brz config --scope breezy hello=world
6622.1.29 by Jelmer Vernooij
Fix some more tests.
246
            $ brz config -d tree --all hello
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
247
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
248
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
249
              hello = world
250
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
251
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
252
    def test_breezy_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
253
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
254
            $ brz config -d tree --scope breezy hello=world
6622.1.29 by Jelmer Vernooij
Fix some more tests.
255
            $ brz config -d tree --all hello
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
256
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
257
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
258
              hello = world
259
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
260
261
    def test_locations_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
262
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
263
            $ brz config -d tree --scope locations hello=world
264
            $ brz config -d tree --all hello
5447.4.20 by Vincent Ladeuil
Indent inplace files.
265
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
266
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
267
              hello = world
268
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
269
270
    def test_branch_config_default(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
271
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
272
            $ brz config -d tree hello=world
273
            $ brz config -d tree --all hello
5447.4.20 by Vincent Ladeuil
Indent inplace files.
274
            branch:
275
              hello = world
276
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
277
278
    def test_branch_config_forcing_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
279
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
280
            $ brz config -d tree --scope branch hello=world
281
            $ brz config -d tree --all hello
5447.4.20 by Vincent Ladeuil
Indent inplace files.
282
            branch:
283
              hello = world
284
            ''')
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
285
286
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
287
class TestConfigRemoveOption(tests.TestCaseWithTransport):
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
288
289
    def setUp(self):
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
290
        super(TestConfigRemoveOption, self).setUp()
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
291
        _t_config.create_configs_with_file_option(self)
292
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
293
    def test_unknown_config(self):
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
294
        self.run_bzr_error(['The "moon" configuration does not exist'],
5447.4.17 by Vincent Ladeuil
Rename config --force to config --scope.
295
                           ['config', '--scope', 'moon', '--remove', 'file'])
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
296
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
297
    def test_breezy_config_outside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
298
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
299
            $ brz config --scope breezy --remove file
6622.1.29 by Jelmer Vernooij
Fix some more tests.
300
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
301
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
302
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
303
              file = locations
304
            branch:
305
              file = branch
306
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
307
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
308
    def test_breezy_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
309
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
310
            $ brz config -d tree --scope breezy --remove file
6622.1.29 by Jelmer Vernooij
Fix some more tests.
311
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
312
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
313
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
314
              file = locations
315
            branch:
316
              file = branch
317
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
318
319
    def test_locations_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
320
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
321
            $ brz config -d tree --scope locations --remove file
322
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
323
            branch:
324
              file = branch
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
325
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
326
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
327
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
328
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
329
330
    def test_branch_config_default(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
331
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
332
            $ brz config -d tree --scope locations --remove file
333
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
334
            branch:
335
              file = branch
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
336
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
337
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
338
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
339
            ''')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
340
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
341
            $ brz config -d tree --remove file
342
            $ brz config -d tree --all file
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
343
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
344
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
345
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
346
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
347
348
    def test_branch_config_forcing_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
349
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
350
            $ brz config -d tree --scope branch --remove file
351
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
352
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
353
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
354
              file = locations
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
355
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
356
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
357
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
358
            ''')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
359
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
360
            $ brz config -d tree --scope locations --remove file
361
            $ brz config -d tree --all file
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
362
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
363
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
364
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
365
            ''')
6270.1.2 by Jelmer Vernooij
Add test for number of roundtrips of 'bzr config -d'.
366
367
6437.66.2 by Vincent Ladeuil
Add a proper tests relying on ':parent' as *a* directory service.
368
class TestConfigDirectory(tests.TestCaseWithTransport):
369
370
    def test_parent_alias(self):
371
        t = self.make_branch_and_tree('base')
372
        t.branch.get_config_stack().set('test', 'base')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
373
        clone = t.branch.controldir.sprout('clone').open_branch()
6437.66.2 by Vincent Ladeuil
Add a proper tests relying on ':parent' as *a* directory service.
374
        clone.get_config_stack().set('test', 'clone')
375
        out, err = self.run_bzr(['config', '-d', ':parent', 'test'],
376
                                working_dir='clone')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
377
        self.assertEqual('base\n', out)