comparison test/test_indexer.py @ 6356:c26b9ce33ae3

issue2551123 - validate indexer_language in configuration.py Was validated in backends/indexer_xapian.py which would throw an error on access rather than on start. Added validator function to CoreConfig class that runs after config.ini is read. At this time we have access to the indexer setting so can determine if xapian is actually going to be used. Moved test into test/test_config.py and pulled validation code from indexer_xapian.py and test/test_indexer.py.
author John Rouillard <rouilj@ieee.org>
date Mon, 29 Mar 2021 22:47:54 -0400
parents 9d209d2b34ae
children 91ab3e0ffcd0
comparison
equal deleted inserted replaced
6355:ac5a6ffa377b 6356:c26b9ce33ae3
193 os.mkdir('test-index') 193 os.mkdir('test-index')
194 from roundup.backends.indexer_xapian import Indexer 194 from roundup.backends.indexer_xapian import Indexer
195 self.dex = Indexer(db) 195 self.dex = Indexer(db)
196 def tearDown(self): 196 def tearDown(self):
197 shutil.rmtree('test-index') 197 shutil.rmtree('test-index')
198 def test_invalid_language(self):
199 """ make sure we have a reasonable error message if
200 invalid language is specified """
201 l = db.config[('main', 'indexer_language')]
202 db.config[('main', 'indexer_language')] = "NO_LANG"
203 from roundup.backends.indexer_xapian import Indexer
204 with self.assertRaises(ValueError) as cm:
205 Indexer(db)
206 # note if Indexer(db) doesn't return ValueError
207 # all Xapian tests after this point will fail.
208 # because a valid langage will not be set.
209 # reset the valid language.
210 db.config[('main', 'indexer_language')] = l
211
212 print(cm)
213 self.assertIn("ValueError", repr(cm.exception))
214 # look for failing language
215 self.assertIn("NO_LANG", cm.exception.args[0])
216 # look for supported language
217 self.assertIn("english", cm.exception.args[0])
218 198
219 class RDBMSIndexerTest(object): 199 class RDBMSIndexerTest(object):
220 def setUp(self): 200 def setUp(self):
221 # remove previous test, ignore errors 201 # remove previous test, ignore errors
222 if os.path.exists(config.DATABASE): 202 if os.path.exists(config.DATABASE):

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