'Helper function to verify whether the discussion tab exists and can be displayed'

def check_discussion(self, tab_list, expected_discussion_link, expected_can_display_value, discussion_link_in_course='', is_staff=True, is_enrolled=True):

    self.course.tabs = tab_list
    self.course.discussion_link = discussion_link_in_course
    discussion_tab = xmodule_tabs.CourseTabList.get_discussion(self.course)
    user = self.create_mock_user(is_authenticated=True, is_staff=is_staff, is_enrolled=is_enrolled)
    with patch('student.models.CourseEnrollment.is_enrolled') as check_is_enrolled:
        check_is_enrolled.return_value = is_enrolled
        self.assertEquals(((discussion_tab is not None) and self.is_tab_enabled(discussion_tab, self.course, user) and (discussion_tab.link_func(self.course, self._reverse(self.course)) == expected_discussion_link)), expected_can_display_value)
