示例#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
    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
    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