comparison test/test_config.py @ 6358:42db48c30d31

Validate indexer values Make sure that indexer values are one of the supported indexers. Invalid values would have raised an invalid indexer exception on access.
author John Rouillard <rouilj@ieee.org>
date Tue, 30 Mar 2021 02:24:22 -0400
parents c985ed52ca2d
children 2d42a308927b
comparison
equal deleted inserted replaced
6357:c985ed52ca2d 6358:42db48c30d31
379 379
380 self.assertEqual(config['HTML_VERSION'], 'html4') 380 self.assertEqual(config['HTML_VERSION'], 'html4')
381 self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG') 381 self.assertEqual(config['INDEXER_LANGUAGE'], 'NO_LANG')
382 382
383 def testInvalidIndexerLanguage_w_xapian(self): 383 def testInvalidIndexerLanguage_w_xapian(self):
384 """ Use explicit xapian indexer. VAerify exception is 384 """ Use explicit xapian indexer. Verify exception is
385 generated. 385 generated.
386 """ 386 """
387 387
388 print("Testing explicit xapian") 388 print("Testing explicit xapian")
389 389
416 self.assertEqual(config[('main', 'html_version')], 'html4') 416 self.assertEqual(config[('main', 'html_version')], 'html4')
417 417
418 # uppercase name passes as does tuple index for setting in web 418 # uppercase name passes as does tuple index for setting in web
419 self.assertEqual(config['WEB_COOKIE_TAKES_PRECEDENCE'], 0) 419 self.assertEqual(config['WEB_COOKIE_TAKES_PRECEDENCE'], 0)
420 self.assertEqual(config[('web','cookie_takes_precedence')], 0) 420 self.assertEqual(config[('web','cookie_takes_precedence')], 0)
421
422
423 def testInvalidIndexerValue(self):
424 """ Mistype native indexer. Verify exception is
425 generated.
426 """
427
428 print("Testing indexer nati")
429
430 self.munge_configini(mods=[ ("indexer = ", "nati") ])
431
432 with self.assertRaises(configuration.OptionValueError) as cm:
433 config.load(self.dirname)
434
435 self.assertIn("OptionValueError", repr(cm.exception))
436 # look for failing value
437 self.assertEqual("nati", cm.exception.args[1])
438 # look for supported values
439 self.assertIn("whoosh", cm.exception.args[2])
440

Roundup Issue Tracker: http://roundup-tracker.org/