@@ -29,7 +29,7 @@ def setUp(self):
29
29
30
30
self .conf = ConfigParser ()
31
31
with open (self .conf_fp , newline = None ) as f :
32
- self .conf .readfp (f )
32
+ self .conf .read_file (f )
33
33
34
34
def tearDown (self ):
35
35
if self .old_conf_fp is not None :
@@ -132,6 +132,8 @@ def test_get_main(self):
132
132
133
133
# Warning raised if No files will be allowed to be uploaded
134
134
# Warning raised if no cookie_secret
135
+ self .conf .set ('main' , 'HELP_EMAIL' , 'ignore@me' )
136
+ self .conf .set ('main' , 'SYSADMIN_EMAIL' , 'ignore@me' )
135
137
with warnings .catch_warnings (record = True ) as warns :
136
138
obs ._get_main (self .conf )
137
139
@@ -180,6 +182,35 @@ def test_get_main(self):
180
182
181
183
self .assertEqual (obs .qiita_env , "" )
182
184
185
+ def test_help_email (self ):
186
+ obs = ConfigurationManager ()
187
+
188
+ with warnings .catch_warnings (record = True ) as warns :
189
+ # warning get only issued when in non test environment
190
+ self .conf .set ('main' , 'TEST_ENVIRONMENT' , 'FALSE' )
191
+
192
+ obs ._get_main (self .conf )
193
+ self .
assertEqual (
obs .
help_email ,
'[email protected] ' )
194
+ self .
assertEqual (
obs .
sysadmin_email ,
'[email protected] ' )
195
+
196
+ obs_warns = [str (w .message ) for w in warns ]
197
+ exp_warns = [
198
+ 'Using the github fake email for HELP_EMAIL, '
199
+ 'are you sure this is OK?' ,
200
+ 'Using the github fake email for SYSADMIN_EMAIL, '
201
+ 'are you sure this is OK?' ]
202
+ self .assertCountEqual (obs_warns , exp_warns )
203
+
204
+ # test if it falls back to [email protected]
205
+ self .conf .set ('main' , 'HELP_EMAIL' , '' )
206
+ with self .assertRaises (ValueError ):
207
+ obs ._get_main (self .conf )
208
+
209
+ # test if it falls back to [email protected]
210
+ self .conf .set ('main' , 'SYSADMIN_EMAIL' , '' )
211
+ with self .assertRaises (ValueError ):
212
+ obs ._get_main (self .conf )
213
+
183
214
def test_get_job_scheduler (self ):
184
215
obs = ConfigurationManager ()
185
216
@@ -214,6 +245,50 @@ def test_get_portal(self):
214
245
obs ._get_portal (self .conf )
215
246
self .assertEqual (obs .portal_dir , "/gold_portal" )
216
247
248
+ def test_get_portal_latlong (self ):
249
+ obs = ConfigurationManager ()
250
+
251
+ # if parameters are given, but not set, they should default to Boulder
252
+ self .assertEqual (obs .stats_map_center_latitude , 40.01027 )
253
+ self .assertEqual (obs .stats_map_center_longitude , - 105.24827 )
254
+
255
+ # a string cannot be parsed as a float
256
+ self .conf .set ('portal' , 'STATS_MAP_CENTER_LATITUDE' , 'kurt' )
257
+ with self .assertRaises (ValueError ):
258
+ obs ._get_portal (self .conf )
259
+
260
+ # check for illegal float values
261
+ self .conf .set ('portal' , 'STATS_MAP_CENTER_LATITUDE' , "-200" )
262
+ with self .assertRaises (ValueError ):
263
+ obs ._get_portal (self .conf )
264
+ self .conf .set ('portal' , 'STATS_MAP_CENTER_LATITUDE' , "200" )
265
+ with self .assertRaises (ValueError ):
266
+ obs ._get_portal (self .conf )
267
+
268
+ # check if value defaults if option is missing altogether
269
+ self .conf .remove_option ('portal' , 'STATS_MAP_CENTER_LATITUDE' )
270
+ obs ._get_portal (self .conf )
271
+ self .assertEqual (obs .stats_map_center_latitude , 40.01027 )
272
+
273
+ # same as above, but for longitude
274
+ # a string cannot be parsed as a float
275
+ self .conf .set ('portal' , 'STATS_MAP_CENTER_LONGITUDE' , 'kurt' )
276
+ with self .assertRaises (ValueError ):
277
+ obs ._get_portal (self .conf )
278
+
279
+ # check for illegal float values
280
+ self .conf .set ('portal' , 'STATS_MAP_CENTER_LONGITUDE' , "-200" )
281
+ with self .assertRaises (ValueError ):
282
+ obs ._get_portal (self .conf )
283
+ self .conf .set ('portal' , 'STATS_MAP_CENTER_LONGITUDE' , "200" )
284
+ with self .assertRaises (ValueError ):
285
+ obs ._get_portal (self .conf )
286
+
287
+ # check if value defaults if option is missing altogether
288
+ self .conf .remove_option ('portal' , 'STATS_MAP_CENTER_LONGITUDE' )
289
+ obs ._get_portal (self .conf )
290
+ self .assertEqual (obs .stats_map_center_longitude , - 105.24827 )
291
+
217
292
218
293
CONF = """
219
294
# ------------------------------ Main settings --------------------------------
@@ -274,6 +349,12 @@ def test_get_portal(self):
274
349
# The value used to secure JWTs for delegated permission artifact download.
275
350
JWT_SECRET = SUPER_SECRET
276
351
352
+ # Address a user should write to when asking for help
353
+
354
+
355
+ # The email address, Qiita sends internal notifications to a sys admin
356
+ SYSADMIN_EMAIL = [email protected]
357
+
277
358
# ----------------------------- SMTP settings -----------------------------
278
359
[smtp]
279
360
# The hostname to connect to
@@ -380,6 +461,14 @@ def test_get_portal(self):
380
461
# Full path to portal styling config file
381
462
PORTAL_FP = /tmp/portal.cfg
382
463
464
+ # The center latitude of the world map, shown on the Stats map.
465
+ # Defaults to 40.01027 (Boulder, CO, USA)
466
+ STATS_MAP_CENTER_LATITUDE =
467
+
468
+ # The center longitude of the world map, shown on the Stats map.
469
+ # Defaults to -105.24827 (Boulder, CO, USA)
470
+ STATS_MAP_CENTER_LONGITUDE =
471
+
383
472
# ----------------------------- iframes settings ---------------------------
384
473
[iframe]
385
474
QIIMP = https://localhost:8898/
0 commit comments