'Verify that enrollments are changed correctly when org was given.'

@patch('student.models.tracker')
def test_with_org_and_invalid_to_mode(self, mock_tracker):

    from_mode = 'audit'
    to_mode = 'no-id-professional'
    self._enroll_users(self.course, self.users, from_mode)
    course_2 = CourseFactory.create(org=self.org)
    CourseModeFactory(course_id=course_2.id, mode_slug=to_mode)
    CourseOverview.load_from_module_store(course_2.id)
    self._enroll_users(course_2, self.users, from_mode)
    self.assertEqual(len(CourseEnrollment.objects.filter(mode=to_mode, course_id=self.course.id)), 0)
    self.assertEqual(len(CourseEnrollment.objects.filter(mode=to_mode, course_id=course_2.id)), 0)
    call_command('bulk_change_enrollment', org=self.org, from_mode=from_mode, to_mode=to_mode, commit=True)
    for user in self.users:
        with self.assertRaises(CourseEnrollment.DoesNotExist):
            CourseEnrollment.objects.get(mode=to_mode, course_id=self.course.id, user=user)
    for user in self.users:
        CourseEnrollment.objects.get(mode=to_mode, course_id=course_2.id, user=user)
        self._assert_mode_changed(mock_tracker, course_2, user, to_mode)
