'Test getting all authors for a course where their permissions run the gamut of allowed group
types.'

def test_get_all_users(self):

    self.assertTrue(CourseInstructorRole(self.course_key).has_user(self.user), "Didn't    add    creator    as    instructor.")
    users = copy.copy(self.users)
    user_by_role = {}
    for role in [CourseInstructorRole, CourseStaffRole, OrgStaffRole, OrgInstructorRole]:
        user_by_role[role] = []
        if ((role is OrgStaffRole) or (role is OrgInstructorRole)):
            group = role(self.course_key.org)
        else:
            group = role(self.course_key)
        user = users.pop()
        group.add_users(user)
        user_by_role[role].append(user)
        self.assertTrue(auth.has_course_author_access(user, self.course_key), '{}    does    not    have    access'.format(user))
    course_team_url = reverse_course_url('course_team_handler', self.course_key)
    response = self.client.get_html(course_team_url)
    for role in [CourseInstructorRole, CourseStaffRole]:
        for user in user_by_role[role]:
            self.assertContains(response, user.email)
    copy_course_key = self.store.make_course_key('copyu', 'copydept.mycourse', 'myrun')
    for role in [CourseInstructorRole, CourseStaffRole, OrgStaffRole, OrgInstructorRole]:
        if ((role is OrgStaffRole) or (role is OrgInstructorRole)):
            auth.add_users(self.user, role(copy_course_key.org), *role(self.course_key.org).users_with_role())
        else:
            auth.add_users(self.user, role(copy_course_key), *role(self.course_key).users_with_role())
    for role in [CourseInstructorRole, CourseStaffRole, OrgStaffRole, OrgInstructorRole]:
        for user in user_by_role[role]:
            if hasattr(user, '_roles'):
                del user._roles
            self.assertTrue(auth.has_course_author_access(user, copy_course_key), '{}    no    copy    access'.format(user))
            if ((role is OrgStaffRole) or (role is OrgInstructorRole)):
                auth.remove_users(self.user, role(self.course_key.org), user)
            else:
                auth.remove_users(self.user, role(self.course_key), user)
            self.assertFalse(auth.has_course_author_access(user, self.course_key), "{}    remove    didn't    work".format(user))
