@@ -245,6 +245,50 @@ def test_get_portal(self):
245
245
obs ._get_portal (self .conf )
246
246
self .assertEqual (obs .portal_dir , "/gold_portal" )
247
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
+
248
292
249
293
CONF = """
250
294
# ------------------------------ Main settings --------------------------------
@@ -417,6 +461,14 @@ def test_get_portal(self):
417
461
# Full path to portal styling config file
418
462
PORTAL_FP = /tmp/portal.cfg
419
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
+
420
472
# ----------------------------- iframes settings ---------------------------
421
473
[iframe]
422
474
QIIMP = https://localhost:8898/
0 commit comments