test_commands.py 文件源码

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

项目:elasticsearch-django 作者: yunojuno 项目源码 文件源码
def test_rebuild_search_index(self, mock_update, mock_create, mock_delete):
        """Test the rebuild_search_index command."""
        cmd = rebuild_search_index.Command()
        result = cmd.do_index_command('foo', interactive=False)  # True would hang the tests
        mock_delete.assert_called_once_with('foo')
        mock_create.assert_called_once_with('foo')
        mock_update.assert_called_once_with('foo')
        self.assertEqual(result['delete'], mock_delete.return_value)
        self.assertEqual(result['create'], mock_create.return_value)
        self.assertEqual(result['update'], mock_update.return_value)
        # check that the delete is handled if the index does not exist
        mock_delete.side_effect = TransportError("Index not found")
        result = cmd.do_index_command('foo', interactive=False)  # True would hang the tests
        self.assertEqual(result['delete'], {})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号