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