diff --git a/lms/djangoapps/ccx/tests/test_field_override_performance.py b/lms/djangoapps/ccx/tests/test_field_override_performance.py index a4af227fe8..5652d51e5c 100644 --- a/lms/djangoapps/ccx/tests/test_field_override_performance.py +++ b/lms/djangoapps/ccx/tests/test_field_override_performance.py @@ -234,7 +234,7 @@ class TestFieldOverrideSplitPerformance(FieldOverridePerformanceTestCase): __test__ = True # TODO: decrease query count as part of REVO-28 - QUERY_COUNT = 31 + QUERY_COUNT = 32 TEST_DATA = { ('no_overrides', 1, True, False): (QUERY_COUNT, 2), diff --git a/lms/djangoapps/course_home_api/course_metadata/tests/test_views.py b/lms/djangoapps/course_home_api/course_metadata/tests/test_views.py index a295c61864..1ff81aaee6 100644 --- a/lms/djangoapps/course_home_api/course_metadata/tests/test_views.py +++ b/lms/djangoapps/course_home_api/course_metadata/tests/test_views.py @@ -3,9 +3,11 @@ Tests for the Course Home Course Metadata API in the Course Home API """ import ddt +import json import mock from django.urls import reverse from edx_toggles.toggles.testutils import override_waffle_flag +from unittest.mock import patch from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.student.models import CourseEnrollment @@ -17,6 +19,7 @@ from lms.djangoapps.courseware.toggles import ( COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES, COURSEWARE_MICROFRONTEND_PROGRESS_MILESTONES_STREAK_CELEBRATION ) +from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration from openedx.features.enterprise_support.tests.factories import ( EnterpriseCourseEnrollmentFactory, EnterpriseCustomerUserFactory @@ -223,3 +226,21 @@ class CourseHomeMetadataTests(BaseCourseHomeTests): assert not enterprise_customer_user_2.active response = self.client.get(self.url) self._assert_course_access_response(response, False, 'incorrect_active_enterprise') + + @patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) + @ddt.data(True, False) + def test_discussion_tab_visible(self, visible): + """ + Tests if discussion tab is visible based on Configuration + """ + CourseInstructorRole(self.course.id).add_users(self.user) + configuration = DiscussionsConfiguration.get(context_key=self.course.id) + configuration.enabled = visible + configuration.save() + response = self.client.get(self.url) + data = json.loads(response.content.decode()) + tab_ids = [tab['tab_id'] for tab in data['tabs']] + if visible: + assert 'discussion' in tab_ids + else: + assert 'discussion' not in tab_ids diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index e4f76f3ab4..5b4aa42f28 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -354,7 +354,7 @@ class IndexQueryTestCase(ModuleStoreTestCase): self.client.login(username=self.user.username, password=self.user_password) CourseEnrollment.enroll(self.user, course.id) - with self.assertNumQueries(202, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): + with self.assertNumQueries(203, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): with check_mongo_calls(3): url = reverse( 'courseware_section', @@ -1487,8 +1487,8 @@ class ProgressPageTests(ProgressPageBaseTests): self.assertContains(resp, "earned a certificate for this course.") @ddt.data( - (True, 52), - (False, 52), + (True, 53), + (False, 53), ) @ddt.unpack def test_progress_queries_paced_courses(self, self_paced, query_count): @@ -1503,13 +1503,13 @@ class ProgressPageTests(ProgressPageBaseTests): ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1)) self.setup_course() with self.assertNumQueries( - 52, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST + 53, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST ), check_mongo_calls(2): self._get_progress_page() for _ in range(2): with self.assertNumQueries( - 36, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST + 37, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST ), check_mongo_calls(2): self._get_progress_page() diff --git a/lms/djangoapps/discussion/plugins.py b/lms/djangoapps/discussion/plugins.py index 83f929b1c7..54898d51c3 100644 --- a/lms/djangoapps/discussion/plugins.py +++ b/lms/djangoapps/discussion/plugins.py @@ -9,6 +9,7 @@ from django.utils.translation import gettext_noop from lms.djangoapps.discussion.toggles import ENABLE_DISCUSSIONS_MFE +from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration from openedx.core.djangoapps.discussions.url_helpers import get_discussions_mfe_url from xmodule.tabs import TabFragmentViewMixin @@ -34,6 +35,8 @@ class DiscussionTab(TabFragmentViewMixin, EnrolledTab): @classmethod def is_enabled(cls, course, user=None): + if not DiscussionsConfiguration.is_enabled(context_key=course.id): + return False if not super().is_enabled(course, user): return False # Disable the regular discussion tab if LTI-based external Discussion forum is enabled diff --git a/openedx/features/course_experience/tests/views/test_course_updates.py b/openedx/features/course_experience/tests/views/test_course_updates.py index f26e1cd35b..851d4d86e6 100644 --- a/openedx/features/course_experience/tests/views/test_course_updates.py +++ b/openedx/features/course_experience/tests/views/test_course_updates.py @@ -49,7 +49,7 @@ class TestCourseUpdatesPage(BaseCourseUpdatesTestCase): # Fetch the view and verify that the query counts haven't changed # TODO: decrease query count as part of REVO-28 - with self.assertNumQueries(53, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): + with self.assertNumQueries(54, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): with check_mongo_calls(3): url = course_updates_url(self.course) self.client.get(url)