bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1704.2.18
by Martin Pool
Remove duplicated TestLocationConfig and update previously hidden tests. (#32587) |
1 |
# Copyright (C) 2005, 2006 by Canonical Ltd
|
|
1442.1.1
by Robert Collins
move config_dir into bzrlib.config |
2 |
# Authors: Robert Collins <robert.collins@canonical.com>
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
18 |
"""Tests for finding and reading the bzr config file[s]."""
|
|
19 |
# import system imports here
|
|
|
1474
by Robert Collins
Merge from Aaron Bentley. |
20 |
from bzrlib.util.configobj.configobj import ConfigObj, ConfigObjError |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
21 |
from cStringIO import StringIO |
|
1442.1.1
by Robert Collins
move config_dir into bzrlib.config |
22 |
import os |
23 |
import sys |
|
24 |
||
25 |
#import bzrlib specific imports here
|
|
26 |
import bzrlib.config as config |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
27 |
import bzrlib.errors as errors |
|
1185.31.25
by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py |
28 |
from bzrlib.tests import TestCase, TestCaseInTempDir |
|
1442.1.1
by Robert Collins
move config_dir into bzrlib.config |
29 |
|
30 |
||
|
1553.6.12
by Erik Bågfors
remove AliasConfig, based on input from abentley |
31 |
sample_long_alias="log -r-15..-1 --line" |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
32 |
sample_config_text = ("[DEFAULT]\n" |
|
1551.2.21
by Aaron Bentley
Formatted unicode config tests as ASCII |
33 |
u"email=Erik B\u00e5gfors <erik@bagfors.nu>\n" |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
34 |
"editor=vim\n" |
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
35 |
"gpg_signing_command=gnome-gpg\n" |
|
1553.2.9
by Erik Bågfors
log_formatter => log_format for "named" formatters |
36 |
"log_format=short\n" |
|
1553.6.12
by Erik Bågfors
remove AliasConfig, based on input from abentley |
37 |
"user_global_option=something\n" |
38 |
"[ALIASES]\n" |
|
39 |
"h=help\n" |
|
40 |
"ll=" + sample_long_alias + "\n") |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
41 |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
42 |
|
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
43 |
sample_always_signatures = ("[DEFAULT]\n" |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
44 |
"check_signatures=ignore\n" |
45 |
"create_signatures=always") |
|
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
46 |
|
47 |
||
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
48 |
sample_ignore_signatures = ("[DEFAULT]\n" |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
49 |
"check_signatures=require\n" |
50 |
"create_signatures=never") |
|
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
51 |
|
52 |
||
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
53 |
sample_maybe_signatures = ("[DEFAULT]\n" |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
54 |
"check_signatures=ignore\n" |
55 |
"create_signatures=when-required") |
|
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
56 |
|
57 |
||
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
58 |
sample_branches_text = ("[http://www.example.com]\n" |
59 |
"# Top level policy\n" |
|
60 |
"email=Robert Collins <robertc@example.org>\n" |
|
61 |
"[http://www.example.com/useglobal]\n" |
|
62 |
"# different project, forces global lookup\n" |
|
63 |
"recurse=false\n" |
|
64 |
"[/b/]\n" |
|
|
1442.1.21
by Robert Collins
create signature_needed() call for commit to trigger creating signatures |
65 |
"check_signatures=require\n" |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
66 |
"# test trailing / matching with no children\n" |
67 |
"[/a/]\n" |
|
|
1442.1.21
by Robert Collins
create signature_needed() call for commit to trigger creating signatures |
68 |
"check_signatures=check-available\n" |
|
1442.1.56
by Robert Collins
gpg_signing_command configuration item |
69 |
"gpg_signing_command=false\n" |
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
70 |
"user_local_option=local\n" |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
71 |
"# test trailing / matching\n" |
72 |
"[/a/*]\n" |
|
73 |
"#subdirs will match but not the parent\n" |
|
74 |
"recurse=False\n" |
|
75 |
"[/a/c]\n" |
|
|
1442.1.21
by Robert Collins
create signature_needed() call for commit to trigger creating signatures |
76 |
"check_signatures=ignore\n" |
|
1185.31.25
by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py |
77 |
"post_commit=bzrlib.tests.test_config.post_commit\n" |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
78 |
"#testing explicit beats globs\n") |
79 |
||
|
1553.6.3
by Erik Bågfors
tests for AliasesConfig |
80 |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
81 |
|
|
1474
by Robert Collins
Merge from Aaron Bentley. |
82 |
class InstrumentedConfigObj(object): |
83 |
"""A config obj look-enough-alike to record calls made to it.""" |
|
84 |
||
|
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
85 |
def __contains__(self, thing): |
86 |
self._calls.append(('__contains__', thing)) |
|
87 |
return False |
|
88 |
||
89 |
def __getitem__(self, key): |
|
90 |
self._calls.append(('__getitem__', key)) |
|
91 |
return self |
|
92 |
||
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
93 |
def __init__(self, input, encoding=None): |
94 |
self._calls = [('__init__', input, encoding)] |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
95 |
|
|
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
96 |
def __setitem__(self, key, value): |
97 |
self._calls.append(('__setitem__', key, value)) |
|
98 |
||
|
1551.2.49
by abentley
Made ConfigObj output binary-identical files on win32 and *nix |
99 |
def write(self, arg): |
|
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
100 |
self._calls.append(('write',)) |
101 |
||
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
102 |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
103 |
class FakeBranch(object): |
104 |
||
105 |
def __init__(self): |
|
106 |
self.base = "http://example.com/branches/demo" |
|
|
1185.65.11
by Robert Collins
Disable inheritance for getting at LockableFiles, rather use composition. |
107 |
self.control_files = FakeControlFiles() |
108 |
||
109 |
||
110 |
class FakeControlFiles(object): |
|
111 |
||
112 |
def __init__(self): |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
113 |
self.email = 'Robert Collins <robertc@example.net>\n' |
114 |
||
|
1185.65.29
by Robert Collins
Implement final review suggestions. |
115 |
def get_utf8(self, filename): |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
116 |
if filename != 'email': |
117 |
raise NotImplementedError |
|
118 |
if self.email is not None: |
|
119 |
return StringIO(self.email) |
|
|
1185.31.45
by John Arbash Meinel
Refactoring Exceptions found some places where the wrong exception was caught. |
120 |
raise errors.NoSuchFile(filename) |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
121 |
|
122 |
||
123 |
class InstrumentedConfig(config.Config): |
|
124 |
"""An instrumented config that supplies stubs for template methods.""" |
|
125 |
||
126 |
def __init__(self): |
|
127 |
super(InstrumentedConfig, self).__init__() |
|
128 |
self._calls = [] |
|
|
1442.1.15
by Robert Collins
make getting the signature checking policy a template method |
129 |
self._signatures = config.CHECK_NEVER |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
130 |
|
131 |
def _get_user_id(self): |
|
132 |
self._calls.append('_get_user_id') |
|
133 |
return "Robert Collins <robert.collins@example.org>" |
|
134 |
||
|
1442.1.15
by Robert Collins
make getting the signature checking policy a template method |
135 |
def _get_signature_checking(self): |
136 |
self._calls.append('_get_signature_checking') |
|
137 |
return self._signatures |
|
138 |
||
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
139 |
|
|
1556.2.2
by Aaron Bentley
Fixed get_bool |
140 |
bool_config = """[DEFAULT] |
141 |
active = true
|
|
142 |
inactive = false
|
|
143 |
[UPPERCASE]
|
|
144 |
active = True
|
|
145 |
nonactive = False
|
|
146 |
"""
|
|
147 |
class TestConfigObj(TestCase): |
|
148 |
def test_get_bool(self): |
|
149 |
from bzrlib.config import ConfigObj |
|
150 |
co = ConfigObj(StringIO(bool_config)) |
|
151 |
self.assertIs(co.get_bool('DEFAULT', 'active'), True) |
|
152 |
self.assertIs(co.get_bool('DEFAULT', 'inactive'), False) |
|
153 |
self.assertIs(co.get_bool('UPPERCASE', 'active'), True) |
|
154 |
self.assertIs(co.get_bool('UPPERCASE', 'nonactive'), False) |
|
155 |
||
156 |
||
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
157 |
class TestConfig(TestCase): |
158 |
||
159 |
def test_constructs(self): |
|
160 |
config.Config() |
|
161 |
||
162 |
def test_no_default_editor(self): |
|
163 |
self.assertRaises(NotImplementedError, config.Config().get_editor) |
|
164 |
||
165 |
def test_user_email(self): |
|
166 |
my_config = InstrumentedConfig() |
|
167 |
self.assertEqual('robert.collins@example.org', my_config.user_email()) |
|
168 |
self.assertEqual(['_get_user_id'], my_config._calls) |
|
169 |
||
170 |
def test_username(self): |
|
171 |
my_config = InstrumentedConfig() |
|
172 |
self.assertEqual('Robert Collins <robert.collins@example.org>', |
|
173 |
my_config.username()) |
|
174 |
self.assertEqual(['_get_user_id'], my_config._calls) |
|
|
1442.1.14
by Robert Collins
Create a default signature checking policy of CHECK_IF_POSSIBLE |
175 |
|
176 |
def test_signatures_default(self): |
|
177 |
my_config = config.Config() |
|
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
178 |
self.assertFalse(my_config.signature_needed()) |
|
1442.1.14
by Robert Collins
Create a default signature checking policy of CHECK_IF_POSSIBLE |
179 |
self.assertEqual(config.CHECK_IF_POSSIBLE, |
180 |
my_config.signature_checking()) |
|
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
181 |
self.assertEqual(config.SIGN_WHEN_REQUIRED, |
182 |
my_config.signing_policy()) |
|
|
1442.1.14
by Robert Collins
Create a default signature checking policy of CHECK_IF_POSSIBLE |
183 |
|
|
1442.1.15
by Robert Collins
make getting the signature checking policy a template method |
184 |
def test_signatures_template_method(self): |
185 |
my_config = InstrumentedConfig() |
|
186 |
self.assertEqual(config.CHECK_NEVER, my_config.signature_checking()) |
|
187 |
self.assertEqual(['_get_signature_checking'], my_config._calls) |
|
188 |
||
189 |
def test_signatures_template_method_none(self): |
|
190 |
my_config = InstrumentedConfig() |
|
191 |
my_config._signatures = None |
|
192 |
self.assertEqual(config.CHECK_IF_POSSIBLE, |
|
193 |
my_config.signature_checking()) |
|
194 |
self.assertEqual(['_get_signature_checking'], my_config._calls) |
|
195 |
||
|
1442.1.56
by Robert Collins
gpg_signing_command configuration item |
196 |
def test_gpg_signing_command_default(self): |
197 |
my_config = config.Config() |
|
198 |
self.assertEqual('gpg', my_config.gpg_signing_command()) |
|
199 |
||
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
200 |
def test_get_user_option_default(self): |
201 |
my_config = config.Config() |
|
202 |
self.assertEqual(None, my_config.get_user_option('no_option')) |
|
203 |
||
|
1472
by Robert Collins
post commit hook, first pass implementation |
204 |
def test_post_commit_default(self): |
205 |
my_config = config.Config() |
|
206 |
self.assertEqual(None, my_config.post_commit()) |
|
207 |
||
|
1553.2.9
by Erik Bågfors
log_formatter => log_format for "named" formatters |
208 |
def test_log_format_default(self): |
|
1553.2.8
by Erik Bågfors
tests for config log_formatter |
209 |
my_config = config.Config() |
|
1553.2.9
by Erik Bågfors
log_formatter => log_format for "named" formatters |
210 |
self.assertEqual('long', my_config.log_format()) |
|
1553.2.8
by Erik Bågfors
tests for config log_formatter |
211 |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
212 |
|
|
1442.1.1
by Robert Collins
move config_dir into bzrlib.config |
213 |
class TestConfigPath(TestCase): |
214 |
||
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
215 |
def setUp(self): |
216 |
super(TestConfigPath, self).setUp() |
|
|
1185.38.5
by John Arbash Meinel
Updating testconfig to handle missing environment variables |
217 |
self.old_home = os.environ.get('HOME', None) |
218 |
self.old_appdata = os.environ.get('APPDATA', None) |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
219 |
os.environ['HOME'] = '/home/bogus' |
|
1185.38.1
by John Arbash Meinel
Adding my win32 patch for moving the home directory. |
220 |
os.environ['APPDATA'] = \ |
221 |
r'C:\Documents and Settings\bogus\Application Data' |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
222 |
|
223 |
def tearDown(self): |
|
|
1185.38.5
by John Arbash Meinel
Updating testconfig to handle missing environment variables |
224 |
if self.old_home is None: |
225 |
del os.environ['HOME'] |
|
226 |
else: |
|
227 |
os.environ['HOME'] = self.old_home |
|
228 |
if self.old_appdata is None: |
|
229 |
del os.environ['APPDATA'] |
|
230 |
else: |
|
231 |
os.environ['APPDATA'] = self.old_appdata |
|
|
1442.1.55
by Robert Collins
move environment preservation up to the root test case, making it available to all tests |
232 |
super(TestConfigPath, self).tearDown() |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
233 |
|
|
1442.1.1
by Robert Collins
move config_dir into bzrlib.config |
234 |
def test_config_dir(self): |
|
1185.38.1
by John Arbash Meinel
Adding my win32 patch for moving the home directory. |
235 |
if sys.platform == 'win32': |
236 |
self.assertEqual(config.config_dir(), |
|
|
1185.31.36
by John Arbash Meinel
Fixup test_config.py to handle new paths |
237 |
'C:/Documents and Settings/bogus/Application Data/bazaar/2.0') |
|
1185.38.1
by John Arbash Meinel
Adding my win32 patch for moving the home directory. |
238 |
else: |
239 |
self.assertEqual(config.config_dir(), '/home/bogus/.bazaar') |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
240 |
|
241 |
def test_config_filename(self): |
|
|
1185.38.1
by John Arbash Meinel
Adding my win32 patch for moving the home directory. |
242 |
if sys.platform == 'win32': |
243 |
self.assertEqual(config.config_filename(), |
|
|
1185.31.36
by John Arbash Meinel
Fixup test_config.py to handle new paths |
244 |
'C:/Documents and Settings/bogus/Application Data/bazaar/2.0/bazaar.conf') |
|
1185.38.1
by John Arbash Meinel
Adding my win32 patch for moving the home directory. |
245 |
else: |
246 |
self.assertEqual(config.config_filename(), |
|
247 |
'/home/bogus/.bazaar/bazaar.conf') |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
248 |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
249 |
def test_branches_config_filename(self): |
|
1185.38.1
by John Arbash Meinel
Adding my win32 patch for moving the home directory. |
250 |
if sys.platform == 'win32': |
251 |
self.assertEqual(config.branches_config_filename(), |
|
|
1185.31.36
by John Arbash Meinel
Fixup test_config.py to handle new paths |
252 |
'C:/Documents and Settings/bogus/Application Data/bazaar/2.0/branches.conf') |
|
1185.38.1
by John Arbash Meinel
Adding my win32 patch for moving the home directory. |
253 |
else: |
254 |
self.assertEqual(config.branches_config_filename(), |
|
255 |
'/home/bogus/.bazaar/branches.conf') |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
256 |
|
|
1770.2.2
by Aaron Bentley
Rename branches.conf to locations.conf |
257 |
def test_locations_config_filename(self): |
258 |
if sys.platform == 'win32': |
|
259 |
self.assertEqual(config.locations_config_filename(), |
|
260 |
'C:/Documents and Settings/bogus/Application Data/bazaar/2.0/locations.conf') |
|
261 |
else: |
|
262 |
self.assertEqual(config.locations_config_filename(), |
|
263 |
'/home/bogus/.bazaar/locations.conf') |
|
264 |
||
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
265 |
class TestIniConfig(TestCase): |
266 |
||
267 |
def test_contructs(self): |
|
268 |
my_config = config.IniBasedConfig("nothing") |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
269 |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
270 |
def test_from_fp(self): |
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
271 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
272 |
my_config = config.IniBasedConfig(None) |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
273 |
self.failUnless( |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
274 |
isinstance(my_config._get_parser(file=config_file), |
|
1474
by Robert Collins
Merge from Aaron Bentley. |
275 |
ConfigObj)) |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
276 |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
277 |
def test_cached(self): |
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
278 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
279 |
my_config = config.IniBasedConfig(None) |
280 |
parser = my_config._get_parser(file=config_file) |
|
281 |
self.failUnless(my_config._get_parser() is parser) |
|
282 |
||
283 |
||
284 |
class TestGetConfig(TestCase): |
|
285 |
||
286 |
def test_constructs(self): |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
287 |
my_config = config.GlobalConfig() |
288 |
||
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
289 |
def test_calls_read_filenames(self): |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
290 |
# replace the class that is constructured, to check its parameters
|
|
1474
by Robert Collins
Merge from Aaron Bentley. |
291 |
oldparserclass = config.ConfigObj |
292 |
config.ConfigObj = InstrumentedConfigObj |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
293 |
my_config = config.GlobalConfig() |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
294 |
try: |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
295 |
parser = my_config._get_parser() |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
296 |
finally: |
|
1474
by Robert Collins
Merge from Aaron Bentley. |
297 |
config.ConfigObj = oldparserclass |
298 |
self.failUnless(isinstance(parser, InstrumentedConfigObj)) |
|
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
299 |
self.assertEqual(parser._calls, [('__init__', config.config_filename(), |
300 |
'utf-8')]) |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
301 |
|
302 |
||
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
303 |
class TestBranchConfig(TestCaseInTempDir): |
304 |
||
305 |
def test_constructs(self): |
|
306 |
branch = FakeBranch() |
|
307 |
my_config = config.BranchConfig(branch) |
|
308 |
self.assertRaises(TypeError, config.BranchConfig) |
|
309 |
||
310 |
def test_get_location_config(self): |
|
311 |
branch = FakeBranch() |
|
312 |
my_config = config.BranchConfig(branch) |
|
313 |
location_config = my_config._get_location_config() |
|
314 |
self.assertEqual(branch.base, location_config.location) |
|
315 |
self.failUnless(location_config is my_config._get_location_config()) |
|
316 |
||
317 |
||
|
1442.1.55
by Robert Collins
move environment preservation up to the root test case, making it available to all tests |
318 |
class TestGlobalConfigItems(TestCase): |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
319 |
|
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
320 |
def test_user_id(self): |
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
321 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
322 |
my_config = config.GlobalConfig() |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
323 |
my_config._parser = my_config._get_parser(file=config_file) |
|
1551.2.21
by Aaron Bentley
Formatted unicode config tests as ASCII |
324 |
self.assertEqual(u"Erik B\u00e5gfors <erik@bagfors.nu>", |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
325 |
my_config._get_user_id()) |
|
1442.1.2
by Robert Collins
create a config module - there is enough config logic to make this worthwhile, and start testing config processing. |
326 |
|
327 |
def test_absent_user_id(self): |
|
328 |
config_file = StringIO("") |
|
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
329 |
my_config = config.GlobalConfig() |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
330 |
my_config._parser = my_config._get_parser(file=config_file) |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
331 |
self.assertEqual(None, my_config._get_user_id()) |
332 |
||
333 |
def test_configured_editor(self): |
|
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
334 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
335 |
my_config = config.GlobalConfig() |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
336 |
my_config._parser = my_config._get_parser(file=config_file) |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
337 |
self.assertEqual("vim", my_config.get_editor()) |
338 |
||
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
339 |
def test_signatures_always(self): |
340 |
config_file = StringIO(sample_always_signatures) |
|
341 |
my_config = config.GlobalConfig() |
|
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
342 |
my_config._parser = my_config._get_parser(file=config_file) |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
343 |
self.assertEqual(config.CHECK_NEVER, |
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
344 |
my_config.signature_checking()) |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
345 |
self.assertEqual(config.SIGN_ALWAYS, |
346 |
my_config.signing_policy()) |
|
|
1442.1.21
by Robert Collins
create signature_needed() call for commit to trigger creating signatures |
347 |
self.assertEqual(True, my_config.signature_needed()) |
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
348 |
|
349 |
def test_signatures_if_possible(self): |
|
350 |
config_file = StringIO(sample_maybe_signatures) |
|
351 |
my_config = config.GlobalConfig() |
|
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
352 |
my_config._parser = my_config._get_parser(file=config_file) |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
353 |
self.assertEqual(config.CHECK_NEVER, |
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
354 |
my_config.signature_checking()) |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
355 |
self.assertEqual(config.SIGN_WHEN_REQUIRED, |
356 |
my_config.signing_policy()) |
|
|
1442.1.21
by Robert Collins
create signature_needed() call for commit to trigger creating signatures |
357 |
self.assertEqual(False, my_config.signature_needed()) |
|
1442.1.17
by Robert Collins
allow global overriding of signature policy to force checking, or (pointless but allowed) to set auto checking |
358 |
|
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
359 |
def test_signatures_ignore(self): |
360 |
config_file = StringIO(sample_ignore_signatures) |
|
361 |
my_config = config.GlobalConfig() |
|
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
362 |
my_config._parser = my_config._get_parser(file=config_file) |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
363 |
self.assertEqual(config.CHECK_ALWAYS, |
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
364 |
my_config.signature_checking()) |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
365 |
self.assertEqual(config.SIGN_NEVER, |
366 |
my_config.signing_policy()) |
|
|
1442.1.21
by Robert Collins
create signature_needed() call for commit to trigger creating signatures |
367 |
self.assertEqual(False, my_config.signature_needed()) |
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
368 |
|
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
369 |
def _get_sample_config(self): |
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
370 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1534.7.154
by Aaron Bentley
Removed changes from bzr.ab 1529..1536 |
371 |
my_config = config.GlobalConfig() |
372 |
my_config._parser = my_config._get_parser(file=config_file) |
|
373 |
return my_config |
|
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
374 |
|
|
1442.1.56
by Robert Collins
gpg_signing_command configuration item |
375 |
def test_gpg_signing_command(self): |
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
376 |
my_config = self._get_sample_config() |
|
1442.1.56
by Robert Collins
gpg_signing_command configuration item |
377 |
self.assertEqual("gnome-gpg", my_config.gpg_signing_command()) |
378 |
self.assertEqual(False, my_config.signature_needed()) |
|
379 |
||
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
380 |
def _get_empty_config(self): |
381 |
config_file = StringIO("") |
|
382 |
my_config = config.GlobalConfig() |
|
383 |
my_config._parser = my_config._get_parser(file=config_file) |
|
384 |
return my_config |
|
385 |
||
|
1442.1.59
by Robert Collins
Add re-sign command to generate a digital signature on a single revision. |
386 |
def test_gpg_signing_command_unset(self): |
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
387 |
my_config = self._get_empty_config() |
|
1442.1.59
by Robert Collins
Add re-sign command to generate a digital signature on a single revision. |
388 |
self.assertEqual("gpg", my_config.gpg_signing_command()) |
389 |
||
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
390 |
def test_get_user_option_default(self): |
391 |
my_config = self._get_empty_config() |
|
392 |
self.assertEqual(None, my_config.get_user_option('no_option')) |
|
393 |
||
394 |
def test_get_user_option_global(self): |
|
395 |
my_config = self._get_sample_config() |
|
396 |
self.assertEqual("something", |
|
397 |
my_config.get_user_option('user_global_option')) |
|
|
1472
by Robert Collins
post commit hook, first pass implementation |
398 |
|
399 |
def test_post_commit_default(self): |
|
400 |
my_config = self._get_sample_config() |
|
401 |
self.assertEqual(None, my_config.post_commit()) |
|
402 |
||
|
1553.2.9
by Erik Bågfors
log_formatter => log_format for "named" formatters |
403 |
def test_configured_logformat(self): |
|
1553.2.8
by Erik Bågfors
tests for config log_formatter |
404 |
my_config = self._get_sample_config() |
|
1553.2.9
by Erik Bågfors
log_formatter => log_format for "named" formatters |
405 |
self.assertEqual("short", my_config.log_format()) |
|
1553.2.8
by Erik Bågfors
tests for config log_formatter |
406 |
|
|
1553.6.12
by Erik Bågfors
remove AliasConfig, based on input from abentley |
407 |
def test_get_alias(self): |
408 |
my_config = self._get_sample_config() |
|
409 |
self.assertEqual('help', my_config.get_alias('h')) |
|
410 |
||
411 |
def test_get_no_alias(self): |
|
412 |
my_config = self._get_sample_config() |
|
413 |
self.assertEqual(None, my_config.get_alias('foo')) |
|
414 |
||
415 |
def test_get_long_alias(self): |
|
416 |
my_config = self._get_sample_config() |
|
417 |
self.assertEqual(sample_long_alias, my_config.get_alias('ll')) |
|
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
418 |
|
|
1704.2.18
by Martin Pool
Remove duplicated TestLocationConfig and update previously hidden tests. (#32587) |
419 |
|
420 |
class TestLocationConfig(TestCaseInTempDir): |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
421 |
|
422 |
def test_constructs(self): |
|
423 |
my_config = config.LocationConfig('http://example.com') |
|
424 |
self.assertRaises(TypeError, config.LocationConfig) |
|
425 |
||
426 |
def test_branch_calls_read_filenames(self): |
|
|
1474
by Robert Collins
Merge from Aaron Bentley. |
427 |
# This is testing the correct file names are provided.
|
428 |
# TODO: consolidate with the test for GlobalConfigs filename checks.
|
|
429 |
#
|
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
430 |
# replace the class that is constructured, to check its parameters
|
|
1474
by Robert Collins
Merge from Aaron Bentley. |
431 |
oldparserclass = config.ConfigObj |
432 |
config.ConfigObj = InstrumentedConfigObj |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
433 |
try: |
|
1770.2.2
by Aaron Bentley
Rename branches.conf to locations.conf |
434 |
my_config = config.LocationConfig('http://www.example.com') |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
435 |
parser = my_config._get_parser() |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
436 |
finally: |
|
1474
by Robert Collins
Merge from Aaron Bentley. |
437 |
config.ConfigObj = oldparserclass |
438 |
self.failUnless(isinstance(parser, InstrumentedConfigObj)) |
|
439 |
self.assertEqual(parser._calls, |
|
|
1770.2.2
by Aaron Bentley
Rename branches.conf to locations.conf |
440 |
[('__init__', config.locations_config_filename(), |
|
1704.2.18
by Martin Pool
Remove duplicated TestLocationConfig and update previously hidden tests. (#32587) |
441 |
'utf-8')]) |
|
1770.2.2
by Aaron Bentley
Rename branches.conf to locations.conf |
442 |
os.mkdir(config.config_dir()) |
443 |
f = file(config.branches_config_filename(), 'wb') |
|
444 |
f.write('') |
|
445 |
f.close() |
|
446 |
oldparserclass = config.ConfigObj |
|
447 |
config.ConfigObj = InstrumentedConfigObj |
|
448 |
try: |
|
449 |
my_config = config.LocationConfig('http://www.example.com') |
|
450 |
parser = my_config._get_parser() |
|
451 |
finally: |
|
452 |
config.ConfigObj = oldparserclass |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
453 |
|
454 |
def test_get_global_config(self): |
|
455 |
my_config = config.LocationConfig('http://example.com') |
|
456 |
global_config = my_config._get_global_config() |
|
457 |
self.failUnless(isinstance(global_config, config.GlobalConfig)) |
|
458 |
self.failUnless(global_config is my_config._get_global_config()) |
|
459 |
||
460 |
def test__get_section_no_match(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
461 |
self.get_location_config('/') |
462 |
self.assertEqual(None, self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
463 |
|
464 |
def test__get_section_exact(self): |
|
|
1442.1.9
by Robert Collins
exact section test passes |
465 |
self.get_location_config('http://www.example.com') |
466 |
self.assertEqual('http://www.example.com', |
|
467 |
self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
468 |
|
469 |
def test__get_section_suffix_does_not(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
470 |
self.get_location_config('http://www.example.com-com') |
471 |
self.assertEqual(None, self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
472 |
|
473 |
def test__get_section_subdir_recursive(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
474 |
self.get_location_config('http://www.example.com/com') |
475 |
self.assertEqual('http://www.example.com', |
|
476 |
self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
477 |
|
478 |
def test__get_section_subdir_matches(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
479 |
self.get_location_config('http://www.example.com/useglobal') |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
480 |
self.assertEqual('http://www.example.com/useglobal', |
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
481 |
self.my_config._get_section()) |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
482 |
|
483 |
def test__get_section_subdir_nonrecursive(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
484 |
self.get_location_config( |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
485 |
'http://www.example.com/useglobal/childbranch') |
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
486 |
self.assertEqual('http://www.example.com', |
487 |
self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
488 |
|
489 |
def test__get_section_subdir_trailing_slash(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
490 |
self.get_location_config('/b') |
491 |
self.assertEqual('/b/', self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
492 |
|
493 |
def test__get_section_subdir_child(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
494 |
self.get_location_config('/a/foo') |
495 |
self.assertEqual('/a/*', self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
496 |
|
497 |
def test__get_section_subdir_child_child(self): |
|
|
1442.1.11
by Robert Collins
LocationConfig lookups for non matching prefixes pass tests |
498 |
self.get_location_config('/a/foo/bar') |
499 |
self.assertEqual('/a/', self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
500 |
|
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
501 |
def test__get_section_trailing_slash_with_children(self): |
502 |
self.get_location_config('/a/') |
|
503 |
self.assertEqual('/a/', self.my_config._get_section()) |
|
504 |
||
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
505 |
def test__get_section_explicit_over_glob(self): |
|
1442.1.10
by Robert Collins
explicit over glob test passes |
506 |
self.get_location_config('/a/c') |
507 |
self.assertEqual('/a/c', self.my_config._get_section()) |
|
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
508 |
|
509 |
||
510 |
def test_location_without_username(self): |
|
511 |
self.get_location_config('http://www.example.com/useglobal') |
|
|
1704.2.18
by Martin Pool
Remove duplicated TestLocationConfig and update previously hidden tests. (#32587) |
512 |
self.assertEqual(u'Erik B\u00e5gfors <erik@bagfors.nu>', |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
513 |
self.my_config.username()) |
514 |
||
515 |
def test_location_not_listed(self): |
|
|
1704.2.18
by Martin Pool
Remove duplicated TestLocationConfig and update previously hidden tests. (#32587) |
516 |
"""Test that the global username is used when no location matches""" |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
517 |
self.get_location_config('/home/robertc/sources') |
|
1704.2.18
by Martin Pool
Remove duplicated TestLocationConfig and update previously hidden tests. (#32587) |
518 |
self.assertEqual(u'Erik B\u00e5gfors <erik@bagfors.nu>', |
|
1442.1.8
by Robert Collins
preparing some tests for LocationConfig |
519 |
self.my_config.username()) |
520 |
||
|
1442.1.13
by Robert Collins
branches.conf is now able to override the users email |
521 |
def test_overriding_location(self): |
522 |
self.get_location_config('http://www.example.com/foo') |
|
523 |
self.assertEqual('Robert Collins <robertc@example.org>', |
|
524 |
self.my_config.username()) |
|
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
525 |
|
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
526 |
def test_signatures_not_set(self): |
527 |
self.get_location_config('http://www.example.com', |
|
528 |
global_config=sample_ignore_signatures) |
|
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
529 |
self.assertEqual(config.CHECK_ALWAYS, |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
530 |
self.my_config.signature_checking()) |
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
531 |
self.assertEqual(config.SIGN_NEVER, |
532 |
self.my_config.signing_policy()) |
|
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
533 |
|
534 |
def test_signatures_never(self): |
|
535 |
self.get_location_config('/a/c') |
|
536 |
self.assertEqual(config.CHECK_NEVER, |
|
537 |
self.my_config.signature_checking()) |
|
538 |
||
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
539 |
def test_signatures_when_available(self): |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
540 |
self.get_location_config('/a/', global_config=sample_ignore_signatures) |
|
1442.1.16
by Robert Collins
allow global overriding of signature policy to never check |
541 |
self.assertEqual(config.CHECK_IF_POSSIBLE, |
542 |
self.my_config.signature_checking()) |
|
|
1442.1.13
by Robert Collins
branches.conf is now able to override the users email |
543 |
|
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
544 |
def test_signatures_always(self): |
545 |
self.get_location_config('/b') |
|
546 |
self.assertEqual(config.CHECK_ALWAYS, |
|
547 |
self.my_config.signature_checking()) |
|
548 |
||
|
1442.1.56
by Robert Collins
gpg_signing_command configuration item |
549 |
def test_gpg_signing_command(self): |
550 |
self.get_location_config('/b') |
|
551 |
self.assertEqual("gnome-gpg", self.my_config.gpg_signing_command()) |
|
552 |
||
553 |
def test_gpg_signing_command_missing(self): |
|
554 |
self.get_location_config('/a') |
|
555 |
self.assertEqual("false", self.my_config.gpg_signing_command()) |
|
556 |
||
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
557 |
def test_get_user_option_global(self): |
558 |
self.get_location_config('/a') |
|
559 |
self.assertEqual('something', |
|
560 |
self.my_config.get_user_option('user_global_option')) |
|
561 |
||
562 |
def test_get_user_option_local(self): |
|
563 |
self.get_location_config('/a') |
|
564 |
self.assertEqual('local', |
|
565 |
self.my_config.get_user_option('user_local_option')) |
|
|
1472
by Robert Collins
post commit hook, first pass implementation |
566 |
|
567 |
def test_post_commit_default(self): |
|
568 |
self.get_location_config('/a/c') |
|
|
1185.31.25
by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py |
569 |
self.assertEqual('bzrlib.tests.test_config.post_commit', |
|
1472
by Robert Collins
post commit hook, first pass implementation |
570 |
self.my_config.post_commit()) |
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
571 |
|
|
1502
by Robert Collins
Bugfix the config test suite to not create .bazaar in the dir where it is run. |
572 |
def get_location_config(self, location, global_config=None): |
573 |
if global_config is None: |
|
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
574 |
global_file = StringIO(sample_config_text.encode('utf-8')) |
|
1502
by Robert Collins
Bugfix the config test suite to not create .bazaar in the dir where it is run. |
575 |
else: |
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
576 |
global_file = StringIO(global_config.encode('utf-8')) |
577 |
branches_file = StringIO(sample_branches_text.encode('utf-8')) |
|
|
1502
by Robert Collins
Bugfix the config test suite to not create .bazaar in the dir where it is run. |
578 |
self.my_config = config.LocationConfig(location) |
579 |
self.my_config._get_parser(branches_file) |
|
580 |
self.my_config._get_global_config()._get_parser(global_file) |
|
581 |
||
|
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
582 |
def test_set_user_setting_sets_and_saves(self): |
583 |
self.get_location_config('/a/c') |
|
584 |
record = InstrumentedConfigObj("foo") |
|
585 |
self.my_config._parser = record |
|
|
1185.62.6
by John Arbash Meinel
Updated test_set_user_setting_sets_and_saves to remove the print statement, and make sure it is doing the right thing |
586 |
|
587 |
real_mkdir = os.mkdir |
|
588 |
self.created = False |
|
589 |
def checked_mkdir(path, mode=0777): |
|
590 |
self.log('making directory: %s', path) |
|
591 |
real_mkdir(path, mode) |
|
592 |
self.created = True |
|
593 |
||
594 |
os.mkdir = checked_mkdir |
|
595 |
try: |
|
596 |
self.my_config.set_user_option('foo', 'bar') |
|
597 |
finally: |
|
598 |
os.mkdir = real_mkdir |
|
599 |
||
600 |
self.failUnless(self.created, 'Failed to create ~/.bazaar') |
|
|
1490
by Robert Collins
Implement a 'bzr push' command, with saved locations; update diff to return 1. |
601 |
self.assertEqual([('__contains__', '/a/c'), |
602 |
('__contains__', '/a/c/'), |
|
603 |
('__setitem__', '/a/c', {}), |
|
604 |
('__getitem__', '/a/c'), |
|
605 |
('__setitem__', 'foo', 'bar'), |
|
606 |
('write',)], |
|
607 |
record._calls[1:]) |
|
608 |
||
|
1185.62.7
by John Arbash Meinel
Whitespace cleanup. |
609 |
|
|
1442.1.55
by Robert Collins
move environment preservation up to the root test case, making it available to all tests |
610 |
class TestBranchConfigItems(TestCase): |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
611 |
|
612 |
def test_user_id(self): |
|
613 |
branch = FakeBranch() |
|
614 |
my_config = config.BranchConfig(branch) |
|
615 |
self.assertEqual("Robert Collins <robertc@example.net>", |
|
616 |
my_config._get_user_id()) |
|
|
1185.65.11
by Robert Collins
Disable inheritance for getting at LockableFiles, rather use composition. |
617 |
branch.control_files.email = "John" |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
618 |
self.assertEqual("John", my_config._get_user_id()) |
619 |
||
620 |
def test_not_set_in_branch(self): |
|
621 |
branch = FakeBranch() |
|
622 |
my_config = config.BranchConfig(branch) |
|
|
1185.65.11
by Robert Collins
Disable inheritance for getting at LockableFiles, rather use composition. |
623 |
branch.control_files.email = None |
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
624 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
625 |
(my_config._get_location_config(). |
|
1442.1.18
by Robert Collins
permit per branch location overriding of signature checking policy |
626 |
_get_global_config()._get_parser(config_file)) |
|
1551.2.21
by Aaron Bentley
Formatted unicode config tests as ASCII |
627 |
self.assertEqual(u"Erik B\u00e5gfors <erik@bagfors.nu>", |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
628 |
my_config._get_user_id()) |
|
1185.65.11
by Robert Collins
Disable inheritance for getting at LockableFiles, rather use composition. |
629 |
branch.control_files.email = "John" |
|
1442.1.6
by Robert Collins
first stage major overhaul of configs, giving use BranchConfigs, LocationConfigs and GlobalConfigs |
630 |
self.assertEqual("John", my_config._get_user_id()) |
631 |
||
632 |
def test_BZREMAIL_OVERRIDES(self): |
|
633 |
os.environ['BZREMAIL'] = "Robert Collins <robertc@example.org>" |
|
634 |
branch = FakeBranch() |
|
635 |
my_config = config.BranchConfig(branch) |
|
636 |
self.assertEqual("Robert Collins <robertc@example.org>", |
|
637 |
my_config.username()) |
|
638 |
||
|
1442.1.19
by Robert Collins
BranchConfigs inherit signature_checking policy from their LocationConfig. |
639 |
def test_signatures_forced(self): |
640 |
branch = FakeBranch() |
|
641 |
my_config = config.BranchConfig(branch) |
|
642 |
config_file = StringIO(sample_always_signatures) |
|
643 |
(my_config._get_location_config(). |
|
644 |
_get_global_config()._get_parser(config_file)) |
|
|
1770.2.1
by Aaron Bentley
Use create_signature for signing policy, deprecate check_signatures for this |
645 |
self.assertEqual(config.CHECK_NEVER, my_config.signature_checking()) |
646 |
self.assertEqual(config.SIGN_ALWAYS, my_config.signing_policy()) |
|
647 |
self.assertTrue(my_config.signature_needed()) |
|
|
1442.1.56
by Robert Collins
gpg_signing_command configuration item |
648 |
|
649 |
def test_gpg_signing_command(self): |
|
650 |
branch = FakeBranch() |
|
651 |
my_config = config.BranchConfig(branch) |
|
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
652 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1442.1.56
by Robert Collins
gpg_signing_command configuration item |
653 |
(my_config._get_location_config(). |
654 |
_get_global_config()._get_parser(config_file)) |
|
655 |
self.assertEqual('gnome-gpg', my_config.gpg_signing_command()) |
|
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
656 |
|
657 |
def test_get_user_option_global(self): |
|
658 |
branch = FakeBranch() |
|
659 |
my_config = config.BranchConfig(branch) |
|
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
660 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1442.1.69
by Robert Collins
config.Config has a 'get_user_option' call that accepts an option name. |
661 |
(my_config._get_location_config(). |
662 |
_get_global_config()._get_parser(config_file)) |
|
663 |
self.assertEqual('something', |
|
664 |
my_config.get_user_option('user_global_option')) |
|
|
1472
by Robert Collins
post commit hook, first pass implementation |
665 |
|
666 |
def test_post_commit_default(self): |
|
667 |
branch = FakeBranch() |
|
668 |
branch.base='/a/c' |
|
669 |
my_config = config.BranchConfig(branch) |
|
|
1551.2.20
by Aaron Bentley
Treated config files as utf-8 |
670 |
config_file = StringIO(sample_config_text.encode('utf-8')) |
|
1472
by Robert Collins
post commit hook, first pass implementation |
671 |
(my_config._get_location_config(). |
672 |
_get_global_config()._get_parser(config_file)) |
|
673 |
branch_file = StringIO(sample_branches_text) |
|
674 |
my_config._get_location_config()._get_parser(branch_file) |
|
|
1185.31.25
by John Arbash Meinel
Renamed all of the tests from selftest/foo.py to tests/test_foo.py |
675 |
self.assertEqual('bzrlib.tests.test_config.post_commit', |
|
1472
by Robert Collins
post commit hook, first pass implementation |
676 |
my_config.post_commit()) |
|
1185.33.31
by Martin Pool
Make annotate cope better with revisions committed without a valid |
677 |
|
678 |
||
679 |
class TestMailAddressExtraction(TestCase): |
|
680 |
||
681 |
def test_extract_email_address(self): |
|
682 |
self.assertEqual('jane@test.com', |
|
683 |
config.extract_email_address('Jane <jane@test.com>')) |
|
684 |
self.assertRaises(errors.BzrError, |
|
685 |
config.extract_email_address, 'Jane Tester') |