def test_it_fetches_the_annotation(self, fetch_annotation, annotation, celery): id_ = 'test-annotation-id' fetch_annotation.return_value = annotation indexer.add_annotation(id_) fetch_annotation.assert_called_once_with(celery.request.db, id_)
def test_it_calls_index_with_annotation(self, fetch_annotation, annotation, index, celery): id_ = 'test-annotation-id' fetch_annotation.return_value = annotation indexer.add_annotation(id_) index.assert_called_once_with(celery.request.es, annotation, celery.request)
def test_it_skips_indexing_when_annotation_cannot_be_loaded( self, fetch_annotation, index, celery): fetch_annotation.return_value = None indexer.add_annotation("test-annotation-id") assert index.called is False
def test_it_calls_index_with_annotation(self, storage, annotation, index, celery): id_ = "test-annotation-id" storage.fetch_annotation.return_value = annotation indexer.add_annotation(id_) index.assert_any_call(celery.request.es, annotation, celery.request)
def test_during_reindex_adds_to_current_index(self, fetch_annotation, annotation, index, celery, settings_service): settings_service.put(SETTING_NEW_INDEX, 'hypothesis-abcdef123') fetch_annotation.return_value = annotation indexer.add_annotation('test-annotation-id') index.assert_any_call(celery.request.es, annotation, celery.request)
def test_during_reindex_adds_to_new_index(self, fetch_annotation, annotation, index, celery, settings_service): settings_service.put('reindex.new_index', 'hypothesis-xyz123') fetch_annotation.return_value = annotation indexer.add_annotation('test-annotation-id') index.assert_any_call(celery.request.es, annotation, celery.request, target_index='hypothesis-xyz123')
def test_during_reindex_adds_to_new_index(self, storage, annotation, index, celery, settings_service): settings_service.put("reindex.new_index", "hypothesis-xyz123") storage.fetch_annotation.return_value = annotation indexer.add_annotation("test-annotation-id") index.assert_any_call( celery.request.es, annotation, celery.request, target_index="hypothesis-xyz123", )
def test_during_reindex_adds_to_new_index(self, fetch_annotation, annotation, index, celery, settings_service): settings_service.put('reindex.new_index', 'hypothesis-abcdef123') settings_service.put('reindex.new_es6_index', 'hypothesis-xyz123') fetch_annotation.return_value = annotation indexer.add_annotation('test-annotation-id') index.assert_any_call(celery.request.es, annotation, celery.request, target_index='hypothesis-abcdef123') index.assert_any_call(celery.request.es6, annotation, celery.request, target_index='hypothesis-xyz123')
def test_add_annotation(self, search_index): indexer.add_annotation(sentinel.annotation_id) search_index.add_annotation_by_id.assert_called_once_with( sentinel.annotation_id)
def test_it_indexes_thread_root(self, fetch_annotation, reply, delay): fetch_annotation.return_value = reply indexer.add_annotation('test-annotation-id') delay.assert_called_once_with('root-id')
def test_it_skips_indexing_when_annotation_cannot_be_loaded(self, fetch_annotation, index, celery): fetch_annotation.return_value = None indexer.add_annotation('test-annotation-id') assert index.called is False
def test_it_indexes_thread_root(self, fetch_annotation, reply, delay): fetch_annotation.return_value = reply indexer.add_annotation("test-annotation-id") delay.assert_called_once_with("root-id")