##// 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 54 :param strip:
55 55 """
56 56 if isinstance(obj, (basestring,)):
57 if obj in ['', ""]:
58 return []
59
57 60 lst = obj.split(sep)
58 61 if strip:
59 62 lst = [v.strip() for v in lst]
@@ -116,11 +119,12 b' class SettingsMaker(object):'
116 119 def _key_transformator(cls, key):
117 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 124 Helper to enable debug on running instance
122 125 :return:
123 126 """
127
124 128 if not str2bool(self.settings.get('logging.autoconfigure')):
125 129 log.info('logging configuration based on main .ini file')
126 130 return
@@ -135,6 +139,14 b' class SettingsMaker(object):'
135 139 with open(logging_conf, 'rb') as f:
136 140 ini_template = textwrap.dedent(f.read())
137 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 150 RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or 'INFO',
139 151 RC_LOGGING_FORMATTER=os.environ.get('RC_LOGGING_FORMATTER', '') or 'generic'
140 152 )
@@ -159,6 +171,7 b' class SettingsMaker(object):'
159 171 'int': self._int_func,
160 172 'list': self._list_func,
161 173 'list:newline': functools.partial(self._list_func, sep='/n'),
174 'list:spacesep': functools.partial(self._list_func, sep=' '),
162 175 'string': functools.partial(self._string_func, lower=lower),
163 176 'dir': self._dir_func,
164 177 'dir:ensured': functools.partial(self._dir_func, ensure_dir=True),
@@ -14,7 +14,10 b' def vcs_app():'
14 14 'dev.use_echo_app': 'true',
15 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 21 app = webtest.TestApp(vcs_app)
19 22 return app
20 23
@@ -25,7 +25,7 b' from vcsserver.base import obfuscate_qs'
25 25 @mock.patch('vcsserver.http_main.VCS', mock.Mock())
26 26 @mock.patch('vcsserver.hgpatches.patch_largefiles_capabilities')
27 27 def test_applies_largefiles_patch(patch_largefiles_capabilities):
28 http_main.main({})
28 http_main.main({'__file__': ''})
29 29 patch_largefiles_capabilities.assert_called_once_with()
30 30
31 31
@@ -35,7 +35,7 b' def test_applies_largefiles_patch(patch_'
35 35 'vcsserver.hgpatches.patch_largefiles_capabilities',
36 36 mock.Mock(side_effect=Exception("Must not be called")))
37 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 41 @pytest.mark.parametrize('given, expected', [
General Comments 0
You need to be logged in to leave comments. Login now