'Queue subtasks while enrolling more students into course in the middle of the process.'

def _queue_subtasks(self, create_subtask_fcn, items_per_task, initial_count, extra_count):

    task_id = str(uuid4())
    instructor_task = InstructorTaskFactory.create(course_id=self.course.id, task_id=task_id, task_key='dummy_task_key', task_type='bulk_course_email')
    self._enroll_students_in_course(self.course.id, initial_count)
    task_querysets = [CourseEnrollment.objects.filter(course_id=self.course.id)]
    def initialize_subtask_info(*args):
        'Instead    of    initializing    subtask    info    enroll    some    more    students    into    course.'
        self._enroll_students_in_course(self.course.id, extra_count)
        return {}
    with patch('lms.djangoapps.instructor_task.subtasks.initialize_subtask_info') as mock_initialize_subtask_info:
        mock_initialize_subtask_info.side_effect = initialize_subtask_info
        queue_subtasks_for_query(entry=instructor_task, action_name='action_name', create_subtask_fcn=create_subtask_fcn, item_querysets=task_querysets, item_fields=[], items_per_task=items_per_task, total_num_items=initial_count)
