282
282
conf_1 = config._Config(conf_file)
283
283
self.assertEquals(True, conf_1.get_udf_autosubscribe())
285
def test_load_share_autosubscribe(self):
286
"""Test load/set/override of share_autosubscribe config value."""
287
conf_file = os.path.join(self.test_root,
288
'test_share_autosubscribe_config.conf')
289
# write some throttling values to the config file
290
with open(conf_file, 'w') as fp:
291
fp.write('[__main__]\n')
292
fp.write('share_autosubscribe = True\n')
294
# keep a original around
295
conf_orig = config._Config(conf_file)
298
conf = config._Config(conf_file)
299
self.assertTrue(conf.get_share_autosubscribe())
301
conf.set_share_autosubscribe(False)
302
self.assertFalse(conf.get_share_autosubscribe())
303
# save, load and check
305
conf_1 = config._Config(conf_file)
306
self.assertFalse(conf_1.get_share_autosubscribe())
308
conf.set_share_autosubscribe(True)
309
self.assertTrue(conf.get_share_autosubscribe())
310
# save, load and check
312
conf_1 = config._Config(conf_file)
313
self.assertTrue(conf_1.get_share_autosubscribe())
315
# load the config, check the override of the value
316
conf = config._Config(conf_file)
317
self.assertTrue(conf.get_share_autosubscribe())
318
overridden_opts = [('__main__', 'share_autosubscribe', False)]
319
conf.override_options(overridden_opts)
320
self.assertFalse(conf.get_share_autosubscribe())
321
self.assertNotEqual(conf.get_share_autosubscribe(),
322
conf_orig.get_share_autosubscribe())
324
conf_1 = config._Config(conf_file)
325
self.assertEquals(True, conf_1.get_share_autosubscribe())
285
327
def test_load_autoconnect(self):
286
328
"""Test load/set/override of autoconnect config value."""
287
329
conf_file = os.path.join(self.test_root,
354
396
bad_value = 'hola'
355
397
invalid_value = None
356
398
parser = config.log_level_parser
357
self.assertEquals(logging.INFO, parser(good_value))
358
self.assertEquals(logging.DEBUG, parser(bad_value))
359
self.assertRaises(TypeError, parser, invalid_value)
399
self.assertEqual(logging.INFO, parser(good_value))
400
self.assertEqual(logging.DEBUG, parser(bad_value))
401
self.assertEqual(logging.DEBUG, parser(invalid_value))
361
403
def test_home_dir_parser(self):
362
404
"""Test home_dir_parser"""
431
473
self.assertEquals(self.cp.get('logging', 'level').value, 10)
433
475
def test_log_level_old_and_new_config(self):
434
"""Test log_level upgrade hook with a mixed config"""
435
conf_file = os.path.join(self.test_root, 'test_old_and_new_config.conf')
436
# write some throttling values to the config file
476
"""Test log_level upgrade hook with a mixed config."""
477
conf_file = os.path.join(self.test_root,
478
'test_old_and_new_config.conf')
479
# write some throttling values to the config file (not default ones)
437
480
with open(conf_file, 'w') as fp:
438
481
fp.write('[__main__]\n')
439
482
fp.write('log_level = NOTE\n')
440
483
fp.write('[logging]\n')
441
fp.write('level = DEBUG\n')
484
fp.write('level = ERROR\n')
442
485
self.assertTrue(os.path.exists(conf_file))
443
486
self.cp.read([conf_file])
444
487
self.cp.parse_all()
445
self.assertEquals(self.cp.get('logging', 'level').value, 10)
488
self.assertEquals(self.cp.get('logging', 'level').value, logging.ERROR)
447
490
def test_old_default_config(self):
448
491
"""Test log_level upgrade hook with an old default config"""