test_cli.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:kinto-elasticsearch 作者: Kinto 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号