예제 #1
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_does_not_run_deleter_if_aliased(self, es, deleter):
        """If dealing with an alias, do not run the deleter."""
        es.get_aliased_index.return_value = 'foobar'

        index.reindex(mock.sentinel.session, es, mock.sentinel.request)

        deleter.delete_all.assert_not_called()
예제 #2
0
파일: index_test.py 프로젝트: zermelozf/h
    def test_it_removes_all_deleted_annotations(self, BatchDeleter):
        index.reindex(mock.sentinel.session, mock.sentinel.es,
                      mock.sentinel.request)

        BatchDeleter.assert_called_once_with(mock.sentinel.session,
                                             mock.sentinel.es)
        assert BatchDeleter.return_value.delete_all.called
예제 #3
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_updates_alias_when_reindexed_if_aliased(self, es, matchers):
        """Call update_aliased_index on the client with the new index name."""
        es.get_aliased_index.return_value = 'foobar'

        index.reindex(mock.sentinel.session, es, mock.sentinel.request)

        es.update_aliased_index.assert_called_once_with(matchers.regex('hypothesis-[0-9a-f]{8}'))
예제 #4
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_creates_new_index_if_aliased(self, es, configure_index, matchers):
        """If the current index isn't concrete, then create a new target index."""
        es.get_aliased_index.return_value = 'foobar'

        index.reindex(mock.sentinel.session, es, mock.sentinel.request)

        configure_index.assert_called_once_with(es, matchers.regex('hypothesis-[0-9a-f]{8}'))
예제 #5
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_passes_new_index_to_indexer_if_aliased(self, es, matchers, BatchIndexer):
        """Pass the name of any new index as target_index to indexer."""
        es.get_aliased_index.return_value = 'foobar'

        index.reindex(mock.sentinel.session, es, mock.sentinel.request)

        _, kwargs = BatchIndexer.call_args
        assert kwargs['target_index'] == matchers.regex('hypothesis-[0-9a-f]{8}')
예제 #6
0
파일: index_test.py 프로젝트: zermelozf/h
    def test_it_indexes_all_annotations(self, BatchIndexer):
        index.reindex(mock.sentinel.session, mock.sentinel.es,
                      mock.sentinel.request)

        BatchIndexer.assert_called_once_with(mock.sentinel.session,
                                             mock.sentinel.es,
                                             mock.sentinel.request)
        assert BatchIndexer.return_value.index_all.called
예제 #7
0
파일: reindex.py 프로젝트: zermelozf/h
def reindex(ctx):
    """
    Reindex all annotations from the PostgreSQL database to the Elasticsearch index.
    """

    request = ctx.obj['bootstrap']()

    index.reindex(request.db, request.es, request)
예제 #8
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_retries_failed_annotations(self, es, indexer):
        """Should call .index() a second time with any failed annotation IDs."""
        indexer.index.return_value = ['abc123', 'def456']

        index.reindex(mock.sentinel.session, es, mock.sentinel.request)

        assert indexer.index.mock_calls == [
            mock.call(),
            mock.call(['abc123', 'def456']),
        ]
예제 #9
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_does_not_update_alias_if_indexing_fails(self, es, indexer):
        """Don't call update_aliased_index if index() fails..."""
        es.get_aliased_index.return_value = 'foobar'
        indexer.index.side_effect = RuntimeError('fail')

        try:
            index.reindex(mock.sentinel.session, es, mock.sentinel.request)
        except RuntimeError:
            pass

        es.update_aliased_index.assert_not_called()
예제 #10
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_indexes_annotations(self, es, indexer):
        """Should call .index() on the batch indexer instance."""
        index.reindex(mock.sentinel.session, es, mock.sentinel.request)

        indexer.index.assert_called_once_with()
예제 #11
0
파일: index_test.py 프로젝트: nlisgo/h
    def test_runs_deleter_if_not_aliased(self, es, deleter):
        """If dealing with a concrete index, run the deleter."""
        index.reindex(mock.sentinel.session, es, mock.sentinel.request)

        deleter.delete_all.assert_called_once_with()
예제 #12
0
파일: indexer.py 프로젝트: zermelozf/h
def reindex_annotations():
    reindex(celery.request.db, celery.request.es, celery.request)
예제 #13
0
파일: indexer.py 프로젝트: nlisgo/h
def reindex_annotations():
    reindex(celery.request.db, celery.request.es, celery.request)
예제 #14
0
파일: index_test.py 프로젝트: pombredanne/h
    def test_it_removes_all_deleted_annotations(self, BatchDeleter):
        index.reindex(mock.sentinel.session, mock.sentinel.es, mock.sentinel.request)

        BatchDeleter.assert_called_once_with(mock.sentinel.session, mock.sentinel.es)
        assert BatchDeleter.return_value.delete_all.called
예제 #15
0
파일: index_test.py 프로젝트: pombredanne/h
    def test_it_indexes_all_annotations(self, BatchIndexer):
        index.reindex(mock.sentinel.session, mock.sentinel.es, mock.sentinel.request)

        BatchIndexer.assert_called_once_with(mock.sentinel.session, mock.sentinel.es, mock.sentinel.request)
        assert BatchIndexer.return_value.index_all.called