def test_index_bad_send_method(self): index = IndexQ(test_config['indexqbase'], 'testq') solr = SolrClient(test_config['SOLR_SERVER'], devel=True, auth=test_config['SOLR_CREDENTIALS']) with self.assertRaises(AttributeError): index.index(solr, test_config['SOLR_COLLECTION'], send_method='Doesnt exist')
def test_index_bad_send_method(self): index = IndexQ(test_config['indexqbase'], 'testq') solr = SolrClient(test_config['SOLR_SERVER'], devel=True, auth=test_config['SOLR_CREDENTIALS']) with self.assertRaises(AttributeError): index.index(solr, test_config['SOLR_COLLECTION'], send_method='Doesnt exist')
def test_index_bad_data(self): index = IndexQ(test_config['indexqbase'], 'testq') solr = SolrClient(test_config['SOLR_SERVER'], devel=True, auth=test_config['SOLR_CREDENTIALS']) if index._is_locked(): index._unlock() self.assertEqual(index.get_all_as_list(),[]) solr.delete_doc_by_id(test_config['SOLR_COLLECTION'],'*') todo_file = index.add({'date':'asd'}, finalize=True) self.assertEqual(index.get_all_as_list()[0],todo_file) with self.assertRaises(SolrError): index.index(solr,test_config['SOLR_COLLECTION']) self.assertEqual(index.get_all_as_list()[0],todo_file) self.assertFalse(index._is_locked())
def test_index_multiproc(self): index = IndexQ(test_config['indexqbase'], 'testq') solr = SolrClient(test_config['SOLR_SERVER'], devel=True, auth=test_config['SOLR_CREDENTIALS']) solr.delete_doc_by_id(test_config['SOLR_COLLECTION'],'*') buff = [] files = [] for doc in self.docs: files.append(index.add(doc, finalize=True)) index.index(solr,test_config['SOLR_COLLECTION'],threads=10) solr.commit(test_config['SOLR_COLLECTION'],openSearcher=True) for doc in self.docs: res = solr.query(test_config['SOLR_COLLECTION'],{'q':'id:{}'.format(doc['id'])}) self.assertTrue(res.get_results_count()==1)
def test_complete_compress_basic_re_indexing(self): log = logging.getLogger() solr = SolrClient(test_config['SOLR_SERVER'], devel=True, auth=test_config['SOLR_CREDENTIALS']) index = IndexQ(test_config['indexqbase'], 'testq', size = 1, log = log, compress=True) solr.delete_doc_by_id(test_config['SOLR_COLLECTION'], '*') for item in self.docs[1:10]: index.add(item, finalize=True) index.index(solr, test_config['SOLR_COLLECTION']) # At this point items are indexed and are moved into the done directory # Lets re-index them to make sure all json got properly encoded files = index.get_all_as_list('_done_dir') for f in index.get_all_as_list('_done_dir'): shutil.move(f, index._todo_dir) index.index(solr, test_config['SOLR_COLLECTION']) self.assertEqual(files, index.get_all_as_list('_done_dir'))
def test_complete_compress_basic_re_indexing(self): log = logging.getLogger() solr = SolrClient(test_config['SOLR_SERVER'], devel=True, auth=test_config['SOLR_CREDENTIALS']) index = IndexQ(test_config['indexqbase'], 'testq', size=1, log=log, compress=True) solr.delete_doc_by_id(test_config['SOLR_COLLECTION'], '*') for item in self.docs[1:10]: index.add(item, finalize=True) index.index(solr, test_config['SOLR_COLLECTION']) # At this point items are indexed and are moved into the done directory # Lets re-index them to make sure all json got properly encoded files = index.get_all_as_list('_done_dir') for f in index.get_all_as_list('_done_dir'): shutil.move(f, index._todo_dir) index.index(solr, test_config['SOLR_COLLECTION']) self.assertEqual(files, index.get_all_as_list('_done_dir'))