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'], {})
评论列表
文章目录