def test_index_chunk_task(self): responses = ResponseFactory.create_batch(10) # With live indexing, that'll create items in the index. Since # we want to test index_chunk_test, we need a clean index to # start with so we delete and recreate it. self.setup_indexes(empty=True) # Verify there's nothing in the index. eq_(len(ResponseMappingType.search()), 0) # Create the record and the chunk and then run it through # celery. batch_id = 'ou812' rec = RecordFactory(batch_id=batch_id) chunk = (to_class_path(ResponseMappingType), [item.id for item in responses]) index_chunk_task.delay(get_index(), batch_id, rec.id, chunk) ResponseMappingType.refresh_index() # Verify everything is in the index now. eq_(len(ResponseMappingType.search()), 10) # Verify the record was marked succeeded. rec = Record.objects.get(pk=rec.id) eq_(rec.status, Record.STATUS_SUCCESS)
def test_index_chunk_task(self): responses = ResponseFactory.create_batch(10) # With live indexing, that'll create items in the index. Since # we want to test index_chunk_test, we need a clean index to # start with so we delete and recreate it. self.setup_indexes(empty=True) # Verify there's nothing in the index. assert ResponseDocType.docs.search().count() == 0 # Create the record and the chunk and then run it through # celery. batch_id = 'ou812' rec = RecordFactory(batch_id=batch_id) chunk = ( to_class_path(ResponseDocType), [item.id for item in responses] ) index_chunk_task.delay(get_index_name(), batch_id, rec.id, chunk) self.refresh() # Verify everything is in the index now. assert ResponseDocType.docs.search().count() == 10 # Verify the record was marked succeeded. rec = Record.objects.get(pk=rec.id) assert rec.status == Record.STATUS_SUCCESS
def test_empty_tr(self): feedback_responses = ResponseFactory.create_batch(5) jane = AnalyzerProfileFactory().user self.client_login_user(jane) data = { 'locales': [], 'products': [], 'versions': [], 'keywords': [], 'url_exists': None } resp = self.client.post( reverse('triggerrule-match'), content_type='application/json', data=json.dumps(data) ) assert resp.status_code == 200 # Note: This matches everything because it's an empty rule. assert ( [item['id'] for item in json.loads(resp.content)['results']] == [fr.id for fr in reversed(feedback_responses)] )