/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
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
28
from ..matchers import ContainsNoVfsCalls
6352.2.2 by Jelmer Vernooij
Use new NoVfsCalls matcher in blackbox tests.
29
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
30
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
31
class TestWithoutConfig(tests.TestCaseWithTransport):
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
32
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
33
    def test_config_all(self):
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
34
        out, err = self.run_bzr(['config'])
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
35
        self.assertEqual('', out)
36
        self.assertEqual('', err)
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
37
5506.2.2 by Vincent Ladeuil
Raise an error if the option doesn't exist and --active is used.
38
    def test_remove_unknown_option(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
39
        self.run_bzr_error(['The "file" configuration option does not exist', ],
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
40
                           ['config', '--remove', 'file'])
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
41
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
42
    def test_all_remove_exclusive(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
43
        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
44
                           ['config', '--remove', '--all'])
45
46
    def test_all_set_exclusive(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
47
        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
48
                           ['config', '--all', 'hello=world'])
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
49
5506.2.2 by Vincent Ladeuil
Raise an error if the option doesn't exist and --active is used.
50
    def test_remove_no_option(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
51
        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.
52
                           ['config', '--remove'])
53
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
54
    def test_unknown_option(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
55
        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
56
                           ['config', 'file'])
57
58
    def test_unexpected_regexp(self):
59
        self.run_bzr_error(
7143.15.2 by Jelmer Vernooij
Run autopep8.
60
            ['The "\\*file" configuration option does not exist', ],
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
61
            ['config', '*file'])
62
63
    def test_wrong_regexp(self):
64
        self.run_bzr_error(
7143.15.2 by Jelmer Vernooij
Run autopep8.
65
            ['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
66
            ['config', '--all', '*file'])
67
5506.2.2 by Vincent Ladeuil
Raise an error if the option doesn't exist and --active is used.
68
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
69
class TestConfigDisplay(tests.TestCaseWithTransport):
70
71
    def setUp(self):
72
        super(TestConfigDisplay, self).setUp()
73
        _t_config.create_configs(self)
74
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
75
    def test_multiline_all_values(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
76
        self.breezy_config.set_user_option('multiline', '1\n2\n')
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
77
        # Fallout from bug 710410, the triple quotes have been toggled
78
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
79
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
80
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
81
              [DEFAULT]
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
82
              multiline = """1
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
83
            2
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
84
            """
85
            ''')
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
86
87
    def test_multiline_value_only(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
88
        self.breezy_config.set_user_option('multiline', '1\n2\n')
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
89
        # Fallout from bug 710410, the triple quotes have been toggled
90
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
91
            $ brz config -d tree multiline
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
92
            """1
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
93
            2
5609.20.3 by Vincent Ladeuil
Fix pqm failures.
94
            """
95
            ''')
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
96
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
97
    def test_list_value_all(self):
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
98
        config.option_registry.register(config.ListOption('list'))
99
        self.addCleanup(config.option_registry.remove, 'list')
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
100
        self.breezy_config.set_user_option('list', [1, 'a', 'with, a comma'])
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
101
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
102
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
103
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
104
              [DEFAULT]
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
105
              list = 1, a, "with, a comma"
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
106
            ''')
107
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
108
    def test_list_value_one(self):
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
109
        config.option_registry.register(config.ListOption('list'))
110
        self.addCleanup(config.option_registry.remove, 'list')
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
111
        self.breezy_config.set_user_option('list', [1, 'a', 'with, a comma'])
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
112
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
113
            $ brz config -d tree list
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
114
            1, a, "with, a comma"
5533.2.1 by Vincent Ladeuil
``bzr config`` properly displays list values
115
            ''')
116
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
117
    def test_registry_value_all(self):
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
118
        self.breezy_config.set_user_option('transform.orphan_policy',
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
119
                                           u'move')
120
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
121
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
122
            breezy:
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
123
              [DEFAULT]
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
124
              transform.orphan_policy = move
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
125
            ''')
126
127
    def test_registry_value_one(self):
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
128
        self.breezy_config.set_user_option('transform.orphan_policy',
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
129
                                           u'move')
130
        script.run_script(self, '''\
6883.13.1 by Jelmer Vernooij
Rename bzr.transform.orphan_policy -> transform.orphan_policy.
131
            $ brz config -d tree transform.orphan_policy
6466.1.1 by Vincent Ladeuil
Fix RegistryOption display in bzr config output
132
            move
133
            ''')
134
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
135
    def test_breezy_config(self):
136
        self.breezy_config.set_user_option('hello', 'world')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
137
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
138
            $ brz config -d tree
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
139
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
140
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
141
              hello = world
142
            ''')
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
143
144
    def test_locations_config_for_branch(self):
145
        self.locations_config.set_user_option('hello', 'world')
146
        self.branch_config.set_user_option('hello', 'you')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
147
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
148
            $ brz config -d tree
5447.4.20 by Vincent Ladeuil
Indent inplace files.
149
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
150
              [.../tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
151
              hello = world
152
            branch:
153
              hello = you
154
            ''')
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
155
156
    def test_locations_config_outside_branch(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
157
        self.breezy_config.set_user_option('hello', 'world')
5447.4.2 by Vincent Ladeuil
Implement the 'brz config' command. Read-only.
158
        self.locations_config.set_user_option('hello', 'world')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
159
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
160
            $ brz config
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
161
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
162
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
163
              hello = world
164
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
165
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
166
    def test_cmd_line(self):
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
167
        self.breezy_config.set_user_option('hello', 'world')
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
168
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
169
            $ brz config -Ohello=bzr
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
170
            cmdline:
171
              hello = bzr
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
172
            breezy:
6404.4.1 by Vincent Ladeuil
Properly support config.CommandLineStore in ``bzr config``
173
              [DEFAULT]
174
              hello = world
175
            ''')
176
6385.1.1 by Vincent Ladeuil
Stores allow Stacks to control when values are quoted/unquoted
177
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
178
class TestConfigDisplayWithPolicy(tests.TestCaseWithTransport):
179
180
    def test_location_with_policy(self):
181
        # LocationConfig is the only one dealing with policies so far.
182
        self.make_branch_and_tree('tree')
183
        config_text = """\
184
[%(dir)s]
185
url = dir
186
url:policy = appendpath
187
[%(dir)s/tree]
188
url = tree
189
""" % {'dir': self.test_dir}
190
        # We don't use the config directly so we save it to disk
191
        config.LocationConfig.from_string(config_text, 'tree', save=True)
192
        # policies are displayed with their options since they are part of
193
        # their definition, likewise the path is not appended, we are just
194
        # presenting the relevant portions of the config files
195
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
196
            $ 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.
197
            locations:
198
              [.../work/tree]
199
              url = tree
200
              [.../work]
201
              url = dir
202
              url:policy = appendpath
203
            ''')
204
5506.2.3 by Vincent Ladeuil
Take review comments into account and drive-by fix bug #670251
205
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
206
class TestConfigActive(tests.TestCaseWithTransport):
207
208
    def setUp(self):
209
        super(TestConfigActive, self).setUp()
210
        _t_config.create_configs_with_file_option(self)
211
212
    def test_active_in_locations(self):
213
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
214
            $ brz config -d tree file
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
215
            locations
216
            ''')
217
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
218
    def test_active_in_breezy(self):
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
219
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
220
            $ brz config -d tree --scope breezy file
221
            breezy
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
222
            ''')
223
224
    def test_active_in_branch(self):
225
        # We need to delete the locations definition that overrides the branch
226
        # one
227
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
228
            $ brz config -d tree --scope locations --remove file
229
            $ brz config -d tree file
5506.2.1 by Vincent Ladeuil
Implements ``bzr config --active option`` displaying only the value.
230
            branch
231
            ''')
232
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
233
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
234
class TestConfigSetOption(tests.TestCaseWithTransport):
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
235
236
    def setUp(self):
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
237
        super(TestConfigSetOption, self).setUp()
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
238
        _t_config.create_configs(self)
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
239
240
    def test_unknown_config(self):
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
241
        self.run_bzr_error(['The "moon" configuration does not exist'],
5447.4.17 by Vincent Ladeuil
Rename config --force to config --scope.
242
                           ['config', '--scope', 'moon', 'hello=world'])
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
243
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
244
    def test_breezy_config_outside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
245
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
246
            $ brz config --scope breezy hello=world
6622.1.29 by Jelmer Vernooij
Fix some more tests.
247
            $ brz config -d tree --all hello
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
248
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
249
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
250
              hello = world
251
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
252
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
253
    def test_breezy_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
254
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
255
            $ brz config -d tree --scope breezy hello=world
6622.1.29 by Jelmer Vernooij
Fix some more tests.
256
            $ brz config -d tree --all hello
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
257
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
258
              [DEFAULT]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
259
              hello = world
260
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
261
262
    def test_locations_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
263
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
264
            $ brz config -d tree --scope locations hello=world
265
            $ brz config -d tree --all hello
5447.4.20 by Vincent Ladeuil
Indent inplace files.
266
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
267
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
268
              hello = world
269
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
270
271
    def test_branch_config_default(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
272
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
273
            $ brz config -d tree hello=world
274
            $ brz config -d tree --all hello
5447.4.20 by Vincent Ladeuil
Indent inplace files.
275
            branch:
276
              hello = world
277
            ''')
5447.4.5 by Vincent Ladeuil
Implement ``bzr config option=value``.
278
279
    def test_branch_config_forcing_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
280
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
281
            $ brz config -d tree --scope branch hello=world
282
            $ brz config -d tree --all hello
5447.4.20 by Vincent Ladeuil
Indent inplace files.
283
            branch:
284
              hello = world
285
            ''')
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
286
287
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
288
class TestConfigRemoveOption(tests.TestCaseWithTransport):
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
289
290
    def setUp(self):
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
291
        super(TestConfigRemoveOption, self).setUp()
5447.4.6 by Vincent Ladeuil
Start defining fixtures but we still have an unexpected sucessful test.
292
        _t_config.create_configs_with_file_option(self)
293
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
294
    def test_unknown_config(self):
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
295
        self.run_bzr_error(['The "moon" configuration does not exist'],
5447.4.17 by Vincent Ladeuil
Rename config --force to config --scope.
296
                           ['config', '--scope', 'moon', '--remove', 'file'])
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
297
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
298
    def test_breezy_config_outside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
299
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
300
            $ brz config --scope breezy --remove file
6622.1.29 by Jelmer Vernooij
Fix some more tests.
301
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
302
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
303
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
304
              file = locations
305
            branch:
306
              file = branch
307
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
308
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
309
    def test_breezy_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
310
        script.run_script(self, '''\
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
311
            $ brz config -d tree --scope breezy --remove file
6622.1.29 by Jelmer Vernooij
Fix some more tests.
312
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
313
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
314
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
315
              file = locations
316
            branch:
317
              file = branch
318
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
319
320
    def test_locations_config_inside_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
321
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
322
            $ brz config -d tree --scope locations --remove file
323
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
324
            branch:
325
              file = branch
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
326
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
327
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
328
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
329
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
330
331
    def test_branch_config_default(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
332
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
333
            $ brz config -d tree --scope locations --remove file
334
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
335
            branch:
336
              file = branch
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
337
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
338
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
339
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
340
            ''')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
341
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
342
            $ brz config -d tree --remove file
343
            $ brz config -d tree --all file
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
344
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
345
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
346
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
347
            ''')
5447.4.11 by Vincent Ladeuil
Implement ``bzr config --remove <option>``.
348
349
    def test_branch_config_forcing_branch(self):
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
350
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
351
            $ brz config -d tree --scope branch --remove file
352
            $ brz config -d tree --all file
5447.4.20 by Vincent Ladeuil
Indent inplace files.
353
            locations:
5533.1.1 by Vincent Ladeuil
Fix ``bzr config`` to respect policies when displaying values and also display sections when appropriate.
354
              [.../work/tree]
5447.4.20 by Vincent Ladeuil
Indent inplace files.
355
              file = locations
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
356
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
357
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
358
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
359
            ''')
5447.4.18 by Vincent Ladeuil
Use a coherent script syntax.
360
        script.run_script(self, '''\
6622.1.29 by Jelmer Vernooij
Fix some more tests.
361
            $ brz config -d tree --scope locations --remove file
362
            $ brz config -d tree --all file
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
363
            breezy:
6393.2.2 by Vincent Ladeuil
Display [DEFAULT] when reporting options from bazaar.conf.
364
              [DEFAULT]
6741 by Jelmer Vernooij
Merge lp:~jelmer/brz/breezy-conf
365
              file = breezy
5447.4.20 by Vincent Ladeuil
Indent inplace files.
366
            ''')
6270.1.2 by Jelmer Vernooij
Add test for number of roundtrips of 'bzr config -d'.
367
368
369
class TestSmartServerConfig(tests.TestCaseWithTransport):
370
371
    def test_simple_branch_config(self):
372
        self.setup_smart_server_with_call_log()
373
        t = self.make_branch_and_tree('branch')
374
        self.reset_smart_call_log()
375
        out, err = self.run_bzr(['config', '-d', self.get_url('branch')])
376
        # This figure represent the amount of work to perform this use case. It
377
        # is entirely ok to reduce this number if a test fails due to rpc_count
378
        # being too low. If rpc_count increases, more network roundtrips have
379
        # become necessary for this use case. Please do not adjust this number
380
        # upwards without agreement from bzr's network support maintainers.
381
        self.assertLength(5, self.hpss_calls)
6366.1.4 by Jelmer Vernooij
Test connection count calls for most blackbox commands.
382
        self.assertLength(1, self.hpss_connections)
6352.2.3 by Jelmer Vernooij
s/NoVfsCalls/ContainsNoVfsCalls/.
383
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
6437.66.2 by Vincent Ladeuil
Add a proper tests relying on ':parent' as *a* directory service.
384
385
386
class TestConfigDirectory(tests.TestCaseWithTransport):
387
388
    def test_parent_alias(self):
389
        t = self.make_branch_and_tree('base')
390
        t.branch.get_config_stack().set('test', 'base')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
391
        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.
392
        clone.get_config_stack().set('test', 'clone')
393
        out, err = self.run_bzr(['config', '-d', ':parent', 'test'],
394
                                working_dir='clone')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
395
        self.assertEqual('base\n', out)