'Check that the `users_in_cohort` response contains the expected list of
users, page number, and total number of pages for a given cohort.  Also
verify that those users are actually in the given cohort.'

def verify_users_in_cohort_and_response(self, cohort, response_dict, expected_users, expected_page, expected_num_pages):

    self.assertTrue(response_dict.get('success'))
    self.assertEqual(response_dict.get('page'), expected_page)
    self.assertEqual(response_dict.get('num_pages'), expected_num_pages)
    returned_users = User.objects.filter(username__in=[user.get('username') for user in response_dict.get('users')])
    self.assertEqual(len(returned_users), len(expected_users))
    self.assertEqual(set(returned_users), set(expected_users))
    self.assertTrue(set(returned_users).issubset(cohort.users.all()))
