def test_cli_logs_elasticsearch_exceptions(self):
indexer = mock.MagicMock()
indexer.bulk().__enter__().index_record.side_effect = elasticsearch.ElasticsearchException
with mock.patch('kinto_elasticsearch.command_reindex.logger') as logger:
with mock.patch('kinto_elasticsearch.command_reindex.get_paginated_records',
return_value=[[{}, {}]]) as get_paginated_records:
reindex_records(indexer,
mock.sentinel.storage,
mock.sentinel.bucket_id,
mock.sentinel.collection_id)
get_paginated_records.assert_called_with(mock.sentinel.storage,
mock.sentinel.bucket_id,
mock.sentinel.collection_id)
logger.exception.assert_called_with('Failed to index record')
评论列表
文章目录