def test_config(self): '''Ensure that various config params are properly handled''' ### Test 'lowercase' param def _check_lc(index, golden_results): '''helper that checks index against golden_results''' for (term, golden_docs) in golden_results: self.assertEqual( set(index.docnames_with_terms(term)), golden_docs) self.assertEqual( set([doc for (doc, score) in index.query(term)]), golden_docs) # test data test_docs = (('doc1', 'Hello There'), ('doc2', 'hello there')) # lowercase=True index = MemorySimIndex() index.set_config('lowercase', True) index.index_string_buffers(test_docs) golden_results = (('hello', {'doc1', 'doc2'}), ('Hello', {'doc1', 'doc2'}), ('HELLO', {'doc1', 'doc2'})) _check_lc(index, golden_results) # lowercase=False index = MemorySimIndex() index.set_config('lowercase', False) index.index_string_buffers(test_docs) golden_results = (('hello', {'doc2'}), ('Hello', {'doc1'}), ('HELLO', set())) _check_lc(index, golden_results)