'Check that add_users_to_cohort returned the expected response and has
the expected side effects.
`expected_added` is a list of users
`expected_changed` is a list of (user, previous_cohort) tuples
`expected_present` is a list of (user, email/username) tuples where
email/username corresponds to the input
`expected_unknown` is a list of strings corresponding to the input
\'expected_preassigned\' is a list of email addresses
\'expected_invalid\' is a list of email addresses'

def verify_added_users_to_cohort(self, response_dict, cohort, course, expected_added, expected_changed, expected_present, expected_unknown, expected_preassigned, expected_invalid):

    self.assertTrue(response_dict.get('success'))
    self.assertEqual(response_dict.get('added'), [{'username': user.username, 'email': user.email} for user in expected_added])
    self.assertEqual(response_dict.get('changed'), [{'username': user.username, 'email': user.email, 'previous_cohort': previous_cohort} for (user, previous_cohort) in expected_changed])
    self.assertEqual(response_dict.get('present'), [username_or_email for (_, username_or_email) in expected_present])
    self.assertEqual(response_dict.get('unknown'), expected_unknown)
    self.assertEqual(response_dict.get('invalid'), expected_invalid)
    self.assertEqual(response_dict.get('preassigned'), expected_preassigned)
    for user in (expected_added + [user for (user, _) in (expected_changed + expected_present)]):
        self.assertEqual(CourseUserGroup.objects.get(course_id=course.id, group_type=CourseUserGroup.COHORT, users__id=user.id), cohort)
