From d314b6ff13fb316fbd3d5e1fdbd827f1e98b8b70 Mon Sep 17 00:00:00 2001 From: ayeshoali Date: Wed, 3 Jan 2024 16:30:33 +0500 Subject: [PATCH 1/3] chore: removed enable_course_live flag --- .../djangoapps/course_live/config/waffle.py | 11 ---------- .../core/djangoapps/course_live/plugins.py | 5 ++--- openedx/core/djangoapps/course_live/tab.py | 2 -- .../djangoapps/course_live/tests/test_tab.py | 14 ++++++------- .../course_live/tests/test_views.py | 20 +++++++++---------- 5 files changed, 17 insertions(+), 35 deletions(-) diff --git a/openedx/core/djangoapps/course_live/config/waffle.py b/openedx/core/djangoapps/course_live/config/waffle.py index 9d4d7c5edac5..f353b4fb3dfd 100644 --- a/openedx/core/djangoapps/course_live/config/waffle.py +++ b/openedx/core/djangoapps/course_live/config/waffle.py @@ -7,17 +7,6 @@ WAFFLE_NAMESPACE = 'course_live' -# .. toggle_name: course_live.enable_course_live -# .. toggle_implementation: CourseWaffleFlag -# .. toggle_default: False -# .. toggle_description: Waffle flag to enable the course live app plugin -# .. toggle_use_cases: temporary, open_edx -# .. toggle_creation_date: 2022-03-02 -# .. toggle_target_removal_date: 2022-06-02 -# .. toggle_warning: When the flag is ON, the course live app will be visible in the course authoring mfe -# .. toggle_tickets: TNL-9603 -ENABLE_COURSE_LIVE = CourseWaffleFlag(f'{WAFFLE_NAMESPACE}.enable_course_live', __name__) - # .. toggle_name: course_live.enable_big_blue_button # .. toggle_implementation: CourseWaffleFlag diff --git a/openedx/core/djangoapps/course_live/plugins.py b/openedx/core/djangoapps/course_live/plugins.py index fbb85a1d1b9f..c211e27a61b0 100644 --- a/openedx/core/djangoapps/course_live/plugins.py +++ b/openedx/core/djangoapps/course_live/plugins.py @@ -10,7 +10,6 @@ from opaque_keys.edx.keys import CourseKey from openedx.core.djangoapps.course_apps.plugins import CourseApp -from openedx.core.djangoapps.course_live.config.waffle import ENABLE_COURSE_LIVE from .models import CourseLiveConfiguration @@ -32,9 +31,9 @@ class LiveCourseApp(CourseApp): @classmethod def is_available(cls, course_key: CourseKey) -> bool: """ - Live is available based on ENABLE_COURSE_LIVE flag + Live is available """ - return ENABLE_COURSE_LIVE.is_enabled(course_key) + return True @classmethod def is_enabled(cls, course_key: CourseKey) -> bool: diff --git a/openedx/core/djangoapps/course_live/tab.py b/openedx/core/djangoapps/course_live/tab.py index 3fe7a64587c8..922900efdd5c 100644 --- a/openedx/core/djangoapps/course_live/tab.py +++ b/openedx/core/djangoapps/course_live/tab.py @@ -8,7 +8,6 @@ from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRole, GlobalStaff from lms.djangoapps.courseware.tabs import EnrolledTab -from openedx.core.djangoapps.course_live.config.waffle import ENABLE_COURSE_LIVE from openedx.core.djangoapps.course_live.models import CourseLiveConfiguration from openedx.core.djangoapps.course_live.providers import HasGlobalCredentials, ProviderManager from openedx.core.lib.cache_utils import request_cached @@ -87,7 +86,6 @@ def is_enabled(cls, course, user=None): Check if the tab is enabled. """ return ( - ENABLE_COURSE_LIVE.is_enabled(course.id) and super().is_enabled(course, user) and CourseLiveConfiguration.is_enabled(course.id) ) diff --git a/openedx/core/djangoapps/course_live/tests/test_tab.py b/openedx/core/djangoapps/course_live/tests/test_tab.py index 0ab2bdfeae6a..7b355276c4a0 100644 --- a/openedx/core/djangoapps/course_live/tests/test_tab.py +++ b/openedx/core/djangoapps/course_live/tests/test_tab.py @@ -10,7 +10,6 @@ from lti_consumer.models import CourseAllowPIISharingInLTIFlag, LtiConfiguration from lms.djangoapps.courseware.tests.test_tabs import TabTestCase -from openedx.core.djangoapps.course_live.config.waffle import ENABLE_COURSE_LIVE from openedx.core.djangoapps.course_live.models import CourseLiveConfiguration from openedx.core.djangoapps.course_live.tab import CourseLiveTab @@ -56,13 +55,12 @@ def test_user_can_access_course_live_tab(self, course_live_config_enabled): self.course_live_config.enabled = course_live_config_enabled self.course_live_config.save() tab = self.check_course_live_tab() - with override_waffle_flag(ENABLE_COURSE_LIVE, True): - self.check_can_display_results( - tab, - for_staff_only=True, - for_enrolled_users_only=True, - expected_value=course_live_config_enabled, - ) + self.check_can_display_results( + tab, + for_staff_only=True, + for_enrolled_users_only=True, + expected_value=course_live_config_enabled, + ) @ddt.data(*itertools.product((True, False), repeat=3)) @ddt.unpack diff --git a/openedx/core/djangoapps/course_live/tests/test_views.py b/openedx/core/djangoapps/course_live/tests/test_views.py index 633ecc3f53f7..ead3b0007d6e 100644 --- a/openedx/core/djangoapps/course_live/tests/test_views.py +++ b/openedx/core/djangoapps/course_live/tests/test_views.py @@ -13,7 +13,7 @@ from xmodule.modulestore.tests.django_utils import CourseUserType, ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from ..config.waffle import ENABLE_COURSE_LIVE, ENABLE_BIG_BLUE_BUTTON +from ..config.waffle import ENABLE_BIG_BLUE_BUTTON from ..models import CourseLiveConfiguration from ..providers import ProviderManager @@ -310,13 +310,12 @@ def test_non_staff_user_access(self): def test_courseware_api_has_live_tab(self): """ - Test if courseware api has live-tab after ENABLE_COURSE_LIVE flag is enabled + Test if courseware api has live-tab """ self.create_course_live_config() - with override_waffle_flag(ENABLE_COURSE_LIVE, True): - url = reverse('course-home:course-metadata', args=[self.course.id]) - response = self.client.get(url) - content = json.loads(response.content.decode('utf-8')) + url = reverse('course-home:course-metadata', args=[self.course.id]) + response = self.client.get(url) + content = json.loads(response.content.decode('utf-8')) data = next((tab for tab in content['tabs'] if tab['tab_id'] == 'lti_live'), None) self.assertEqual(data, { 'tab_id': 'lti_live', @@ -432,11 +431,10 @@ def test_api_returns_live_iframe(self): lti_1p1_client_secret='test_client_secret', ) live_config.save() - with override_waffle_flag(ENABLE_COURSE_LIVE, True): - response = self.client.get(self.url) - self.assertEqual(response.status_code, 200) - self.assertIsInstance(response.data['iframe'], Markup) - self.assertIn('iframe', str(response.data['iframe'])) + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) + self.assertIsInstance(response.data['iframe'], Markup) + self.assertIn('iframe', str(response.data['iframe'])) def test_non_authenticated_user(self): """ From c5289fb6b91d19a9713f3cd726e01bb568f1a50c Mon Sep 17 00:00:00 2001 From: ayeshoali Date: Wed, 3 Jan 2024 17:06:06 +0500 Subject: [PATCH 2/3] chore: removed enable_big_blue_button flag --- .../tests/test_field_override_performance.py | 2 +- .../courseware/tests/test_model_data.py | 2 +- lms/djangoapps/courseware/tests/test_views.py | 10 +++++----- .../djangoapps/course_live/config/waffle.py | 20 ------------------- .../core/djangoapps/course_live/providers.py | 4 +--- .../djangoapps/course_live/tests/test_tab.py | 1 - .../course_live/tests/test_views.py | 4 ---- .../tests/views/test_course_updates.py | 2 +- 8 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 openedx/core/djangoapps/course_live/config/waffle.py diff --git a/lms/djangoapps/ccx/tests/test_field_override_performance.py b/lms/djangoapps/ccx/tests/test_field_override_performance.py index 5652d51e5cfd..68926a24f2dd 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 = 32 + QUERY_COUNT = 33 TEST_DATA = { ('no_overrides', 1, True, False): (QUERY_COUNT, 2), diff --git a/lms/djangoapps/courseware/tests/test_model_data.py b/lms/djangoapps/courseware/tests/test_model_data.py index 6c763d57b338..e26c93b7acd7 100644 --- a/lms/djangoapps/courseware/tests/test_model_data.py +++ b/lms/djangoapps/courseware/tests/test_model_data.py @@ -276,7 +276,7 @@ def test_set_field_in_missing_student_module(self): # on the StudentModule). # Django 1.8 also has a number of other BEGIN and SAVESTATE queries. with self.assertNumQueries(4, using='default'): - with self.assertNumQueries(2, using='student_module_history'): + with self.assertNumQueries(1, using='student_module_history'): self.kvs.set(user_state_key('a_field'), 'a_value') assert 1 == sum(len(cache) for cache in self.field_data_cache.cache.values()) diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 8b7667ec2710..19d6965e75c0 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -365,7 +365,7 @@ def test_index_query_counts(self): self.client.login(username=self.user.username, password=self.user_password) CourseEnrollment.enroll(self.user, course.id) - with self.assertNumQueries(177, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): + with self.assertNumQueries(178, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): with check_mongo_calls(3): url = reverse( 'courseware_section', @@ -1491,8 +1491,8 @@ def test_view_certificate_link(self): self.assertContains(resp, "earned a certificate for this course.") @ddt.data( - (True, 53), - (False, 53), + (True, 54), + (False, 54), ) @ddt.unpack def test_progress_queries_paced_courses(self, self_paced, query_count): @@ -1507,13 +1507,13 @@ def test_progress_queries(self): ContentTypeGatingConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1)) self.setup_course() with self.assertNumQueries( - 53, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST + 54, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST ), check_mongo_calls(2): self._get_progress_page() for _ in range(2): with self.assertNumQueries( - 37, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST + 38, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST ), check_mongo_calls(2): self._get_progress_page() diff --git a/openedx/core/djangoapps/course_live/config/waffle.py b/openedx/core/djangoapps/course_live/config/waffle.py deleted file mode 100644 index f353b4fb3dfd..000000000000 --- a/openedx/core/djangoapps/course_live/config/waffle.py +++ /dev/null @@ -1,20 +0,0 @@ -""" -This module contains various configuration settings via -waffle switches for the live app. -""" - -from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag - -WAFFLE_NAMESPACE = 'course_live' - - -# .. toggle_name: course_live.enable_big_blue_button -# .. toggle_implementation: CourseWaffleFlag -# .. toggle_default: False -# .. toggle_description: Waffle flag to enable big blue button provider -# .. toggle_use_cases: temporary, open_edx -# .. toggle_creation_date: 2022-06-23 -# .. toggle_target_removal_date: 2022-09-23 -# .. toggle_warning: When the flag is ON, the big blue button provider will be available in course live -# .. toggle_tickets: INF-308 -ENABLE_BIG_BLUE_BUTTON = CourseWaffleFlag(f'{WAFFLE_NAMESPACE}.enable_big_blue_button', __name__) diff --git a/openedx/core/djangoapps/course_live/providers.py b/openedx/core/djangoapps/course_live/providers.py index 1d6b1e808edb..5379ae260b7a 100644 --- a/openedx/core/djangoapps/course_live/providers.py +++ b/openedx/core/djangoapps/course_live/providers.py @@ -5,8 +5,6 @@ from typing import List, Dict from django.conf import settings -from openedx.core.djangoapps.course_live.config.waffle import ENABLE_BIG_BLUE_BUTTON - class LiveProvider(ABC): """ @@ -120,7 +118,7 @@ def has_free_tier(self) -> bool: @property def is_enabled(self) -> bool: - return ENABLE_BIG_BLUE_BUTTON.is_enabled() + return True @staticmethod def get_global_keys() -> Dict: diff --git a/openedx/core/djangoapps/course_live/tests/test_tab.py b/openedx/core/djangoapps/course_live/tests/test_tab.py index 7b355276c4a0..1a69434b7985 100644 --- a/openedx/core/djangoapps/course_live/tests/test_tab.py +++ b/openedx/core/djangoapps/course_live/tests/test_tab.py @@ -6,7 +6,6 @@ import ddt from django.test import RequestFactory -from edx_toggles.toggles.testutils import override_waffle_flag from lti_consumer.models import CourseAllowPIISharingInLTIFlag, LtiConfiguration from lms.djangoapps.courseware.tests.test_tabs import TabTestCase diff --git a/openedx/core/djangoapps/course_live/tests/test_views.py b/openedx/core/djangoapps/course_live/tests/test_views.py index ead3b0007d6e..97ed4c9ce194 100644 --- a/openedx/core/djangoapps/course_live/tests/test_views.py +++ b/openedx/core/djangoapps/course_live/tests/test_views.py @@ -5,7 +5,6 @@ import ddt from django.test import RequestFactory from django.urls import reverse -from edx_toggles.toggles.testutils import override_waffle_flag from lti_consumer.models import CourseAllowPIISharingInLTIFlag, LtiConfiguration from markupsafe import Markup from rest_framework.test import APITestCase @@ -13,13 +12,11 @@ from xmodule.modulestore.tests.django_utils import CourseUserType, ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from ..config.waffle import ENABLE_BIG_BLUE_BUTTON from ..models import CourseLiveConfiguration from ..providers import ProviderManager @ddt.ddt -@override_waffle_flag(ENABLE_BIG_BLUE_BUTTON, True) class TestCourseLiveConfigurationView(ModuleStoreTestCase, APITestCase): """ Unit tests for the CourseLiveConfigurationView. @@ -355,7 +352,6 @@ def test_create_configurations_response_free_tier(self, provider, share_email, s self.assertEqual(content, expected_data) -@override_waffle_flag(ENABLE_BIG_BLUE_BUTTON, True) class TestCourseLiveProvidersView(ModuleStoreTestCase, APITestCase): """ Tests for course live provider view 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 379be52ed40f..f26e1cd35ba2 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 @@ def test_queries(self): # Fetch the view and verify that the query counts haven't changed # TODO: decrease query count as part of REVO-28 - with self.assertNumQueries(52, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): + with self.assertNumQueries(53, table_ignorelist=QUERY_COUNT_TABLE_IGNORELIST): with check_mongo_calls(3): url = course_updates_url(self.course) self.client.get(url) From f66eba219165fde8ea42de042ac79c3d8596708a Mon Sep 17 00:00:00 2001 From: ayeshoali Date: Wed, 10 Jan 2024 14:37:08 +0500 Subject: [PATCH 3/3] fix: fixing failed test cases --- lms/djangoapps/courseware/tests/test_model_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/courseware/tests/test_model_data.py b/lms/djangoapps/courseware/tests/test_model_data.py index e26c93b7acd7..6c763d57b338 100644 --- a/lms/djangoapps/courseware/tests/test_model_data.py +++ b/lms/djangoapps/courseware/tests/test_model_data.py @@ -276,7 +276,7 @@ def test_set_field_in_missing_student_module(self): # on the StudentModule). # Django 1.8 also has a number of other BEGIN and SAVESTATE queries. with self.assertNumQueries(4, using='default'): - with self.assertNumQueries(1, using='student_module_history'): + with self.assertNumQueries(2, using='student_module_history'): self.kvs.set(user_state_key('a_field'), 'a_value') assert 1 == sum(len(cache) for cache in self.field_data_cache.cache.values())