'Test that the CohortPartitionScheme continues to return the correct
group for a student as the student is moved in and out of different
cohorts.'

def test_student_cohort_assignment(self):

    (first_cohort, second_cohort) = [CohortFactory(course_id=self.course_key) for _ in range(2)]
    add_user_to_cohort(first_cohort, self.student.username)
    self.assert_student_in_group(None)
    link_cohort_to_partition_group(first_cohort, self.user_partition.id, self.groups[0].id)
    link_cohort_to_partition_group(second_cohort, self.user_partition.id, self.groups[1].id)
    self.assert_student_in_group(self.groups[0])
    add_user_to_cohort(second_cohort, self.student.username)
    self.assert_student_in_group(self.groups[1])
    remove_user_from_cohort(second_cohort, self.student.username)
    self.assert_student_in_group(None)
