1
# Copyright (C) 2010 Canonical Ltd
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.
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.
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
18
"""Black-box tests for bzr config."""
27
from bzrlib.tests import (
29
test_config as _t_config,
32
class TestWithoutConfig(tests.TestCaseWithTransport):
34
def test_no_config(self):
35
out, err = self.run_bzr(['config'])
36
self.assertEquals('', out)
37
self.assertEquals('', err)
39
def test_all_variables_no_config(self):
40
out, err = self.run_bzr(['config', '*'])
41
self.assertEquals('', out)
42
self.assertEquals('', err)
44
def test_unknown_option(self):
45
self.run_bzr_error(['The "file" configuration option does not exist',],
46
['config', '--remove', 'file'])
48
class TestConfigDisplay(tests.TestCaseWithTransport):
51
super(TestConfigDisplay, self).setUp()
52
_t_config.create_configs(self)
54
def test_bazaar_config(self):
55
self.bazaar_config.set_user_option('hello', 'world')
56
script.run_script(self, '''\
62
def test_locations_config_for_branch(self):
63
self.locations_config.set_user_option('hello', 'world')
64
self.branch_config.set_user_option('hello', 'you')
65
script.run_script(self, '''\
73
def test_locations_config_outside_branch(self):
74
self.bazaar_config.set_user_option('hello', 'world')
75
self.locations_config.set_user_option('hello', 'world')
76
script.run_script(self, '''\
83
class TestConfigSetOption(tests.TestCaseWithTransport):
86
super(TestConfigSetOption, self).setUp()
87
_t_config.create_configs(self)
89
def test_unknown_config(self):
90
self.run_bzr_error(['The "moon" configuration does not exist'],
91
['config', '--scope', 'moon', 'hello=world'])
93
def test_bazaar_config_outside_branch(self):
94
script.run_script(self, '''\
95
$ bzr config --scope bazaar hello=world
96
$ bzr config -d tree hello
101
def test_bazaar_config_inside_branch(self):
102
script.run_script(self, '''\
103
$ bzr config -d tree --scope bazaar hello=world
104
$ bzr config -d tree hello
109
def test_locations_config_inside_branch(self):
110
script.run_script(self, '''\
111
$ bzr config -d tree --scope locations hello=world
112
$ bzr config -d tree hello
117
def test_branch_config_default(self):
118
script.run_script(self, '''\
119
$ bzr config -d tree hello=world
120
$ bzr config -d tree hello
125
def test_branch_config_forcing_branch(self):
126
script.run_script(self, '''\
127
$ bzr config -d tree --scope branch hello=world
128
$ bzr config -d tree hello
134
class TestConfigRemoveOption(tests.TestCaseWithTransport):
137
super(TestConfigRemoveOption, self).setUp()
138
_t_config.create_configs_with_file_option(self)
140
def test_unknown_config(self):
141
self.run_bzr_error(['The "moon" configuration does not exist'],
142
['config', '--scope', 'moon', '--remove', 'file'])
144
def test_bazaar_config_outside_branch(self):
145
script.run_script(self, '''\
146
$ bzr config --scope bazaar --remove file
147
$ bzr config -d tree file
154
def test_bazaar_config_inside_branch(self):
155
script.run_script(self, '''\
156
$ bzr config -d tree --scope bazaar --remove file
157
$ bzr config -d tree file
164
def test_locations_config_inside_branch(self):
165
script.run_script(self, '''\
166
$ bzr config -d tree --scope locations --remove file
167
$ bzr config -d tree file
174
def test_branch_config_default(self):
175
script.run_script(self, '''\
176
$ bzr config -d tree --remove file
177
$ bzr config -d tree file
183
script.run_script(self, '''\
184
$ bzr config -d tree --remove file
185
$ bzr config -d tree file
190
def test_branch_config_forcing_branch(self):
191
script.run_script(self, '''\
192
$ bzr config -d tree --scope branch --remove file
193
$ bzr config -d tree file
199
script.run_script(self, '''\
200
$ bzr config -d tree --remove file
201
$ bzr config -d tree file