'Tests group access for retrieving a thread
All privileged roles are able to retrieve a thread. A student role can
only retrieve a thread if,
the student role is the author and the thread is not in a cohort,
the student role is the author and the thread is in the author\'s cohort.'

@ddt.data(*itertools.product([FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR, FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_STUDENT], [True, False], ['no_group', 'match_group', 'different_group']))
@ddt.unpack
def test_group_access(self, role_name, course_is_cohorted, thread_group_state):

    (cohort_course, cohort) = _create_course_and_cohort_with_user_role(course_is_cohorted, self.user, role_name)
    self.register_thread({'course_id': unicode(cohort_course.id), 'group_id': (None if (thread_group_state == 'no_group') else (cohort.id if (thread_group_state == 'match_group') else (cohort.id + 1)))})
    expected_error = ((role_name == FORUM_ROLE_STUDENT) and course_is_cohorted and (thread_group_state == 'different_group'))
    try:
        get_thread(self.request, self.thread_id)
        self.assertFalse(expected_error)
    except ThreadNotFoundError:
        self.assertTrue(expected_error)
