'Submit a task and mock how celery provides a current_task.'

def _run_task_with_mock_celery(self, task_class, entry_id, task_id, expected_failure_message=None):

    self.current_task = Mock()
    self.current_task.request = Mock()
    self.current_task.request.id = task_id
    self.current_task.update_state = Mock()
    if (expected_failure_message is not None):
        self.current_task.update_state.side_effect = TestTaskFailure(expected_failure_message)
    task_args = [entry_id, self._get_xmodule_instance_args()]
    with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task') as mock_get_task:
        mock_get_task.return_value = self.current_task
        return task_class.apply(task_args, task_id=task_id).get()
