##// END OF EJS Templates
vcsserver: fixed settings maker tests
super-admin -
r1022:ff345e8f default
parent child Browse files
Show More
@@ -54,6 +54,9 b' def aslist(obj, sep=None, strip=True):'
54 :param strip:
54 :param strip:
55 """
55 """
56 if isinstance(obj, (basestring,)):
56 if isinstance(obj, (basestring,)):
57 if obj in ['', ""]:
58 return []
59
57 lst = obj.split(sep)
60 lst = obj.split(sep)
58 if strip:
61 if strip:
59 lst = [v.strip() for v in lst]
62 lst = [v.strip() for v in lst]
@@ -116,11 +119,12 b' class SettingsMaker(object):'
116 def _key_transformator(cls, key):
119 def _key_transformator(cls, key):
117 return "{}_{}".format('RC'.upper(), key.upper().replace('.', '_').replace('-', '_'))
120 return "{}_{}".format('RC'.upper(), key.upper().replace('.', '_').replace('-', '_'))
118
121
119 def enable_logging(self, logging_conf=None):
122 def enable_logging(self, logging_conf=None, level='INFO', formatter='generic'):
120 """
123 """
121 Helper to enable debug on running instance
124 Helper to enable debug on running instance
122 :return:
125 :return:
123 """
126 """
127
124 if not str2bool(self.settings.get('logging.autoconfigure')):
128 if not str2bool(self.settings.get('logging.autoconfigure')):
125 log.info('logging configuration based on main .ini file')
129 log.info('logging configuration based on main .ini file')
126 return
130 return
@@ -135,6 +139,14 b' class SettingsMaker(object):'
135 with open(logging_conf, 'rb') as f:
139 with open(logging_conf, 'rb') as f:
136 ini_template = textwrap.dedent(f.read())
140 ini_template = textwrap.dedent(f.read())
137 ini_template = string.Template(ini_template).safe_substitute(
141 ini_template = string.Template(ini_template).safe_substitute(
142 RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or level,
143 RC_LOGGING_FORMATTER=os.environ.get('RC_LOGGING_FORMATTER', '') or formatter
144 )
145
146
147 with open(logging_conf, 'rb') as f:
148 ini_template = textwrap.dedent(f.read())
149 ini_template = string.Template(ini_template).safe_substitute(
138 RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or 'INFO',
150 RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or 'INFO',
139 RC_LOGGING_FORMATTER=os.environ.get('RC_LOGGING_FORMATTER', '') or 'generic'
151 RC_LOGGING_FORMATTER=os.environ.get('RC_LOGGING_FORMATTER', '') or 'generic'
140 )
152 )
@@ -159,6 +171,7 b' class SettingsMaker(object):'
159 'int': self._int_func,
171 'int': self._int_func,
160 'list': self._list_func,
172 'list': self._list_func,
161 'list:newline': functools.partial(self._list_func, sep='/n'),
173 'list:newline': functools.partial(self._list_func, sep='/n'),
174 'list:spacesep': functools.partial(self._list_func, sep=' '),
162 'string': functools.partial(self._string_func, lower=lower),
175 'string': functools.partial(self._string_func, lower=lower),
163 'dir': self._dir_func,
176 'dir': self._dir_func,
164 'dir:ensured': functools.partial(self._dir_func, ensure_dir=True),
177 'dir:ensured': functools.partial(self._dir_func, ensure_dir=True),
@@ -14,7 +14,10 b' def vcs_app():'
14 'dev.use_echo_app': 'true',
14 'dev.use_echo_app': 'true',
15 'locale': 'en_US.UTF-8',
15 'locale': 'en_US.UTF-8',
16 }
16 }
17 vcs_app = main({}, **stub_settings)
17 stub_global_conf = {
18 '__file__': ''
19 }
20 vcs_app = main(stub_global_conf, **stub_settings)
18 app = webtest.TestApp(vcs_app)
21 app = webtest.TestApp(vcs_app)
19 return app
22 return app
20
23
@@ -25,7 +25,7 b' from vcsserver.base import obfuscate_qs'
25 @mock.patch('vcsserver.http_main.VCS', mock.Mock())
25 @mock.patch('vcsserver.http_main.VCS', mock.Mock())
26 @mock.patch('vcsserver.hgpatches.patch_largefiles_capabilities')
26 @mock.patch('vcsserver.hgpatches.patch_largefiles_capabilities')
27 def test_applies_largefiles_patch(patch_largefiles_capabilities):
27 def test_applies_largefiles_patch(patch_largefiles_capabilities):
28 http_main.main({})
28 http_main.main({'__file__': ''})
29 patch_largefiles_capabilities.assert_called_once_with()
29 patch_largefiles_capabilities.assert_called_once_with()
30
30
31
31
@@ -35,7 +35,7 b' def test_applies_largefiles_patch(patch_'
35 'vcsserver.hgpatches.patch_largefiles_capabilities',
35 'vcsserver.hgpatches.patch_largefiles_capabilities',
36 mock.Mock(side_effect=Exception("Must not be called")))
36 mock.Mock(side_effect=Exception("Must not be called")))
37 def test_applies_largefiles_patch_only_if_mercurial_is_available():
37 def test_applies_largefiles_patch_only_if_mercurial_is_available():
38 http_main.main({})
38 http_main.main({'__file__': ''})
39
39
40
40
41 @pytest.mark.parametrize('given, expected', [
41 @pytest.mark.parametrize('given, expected', [
General Comments 0
You need to be logged in to leave comments. Login now