From 8e8bb57b3bb83ed8c834a160d3977c2fde8b1d39 Mon Sep 17 00:00:00 2001 From: Ahtisham Shahid Date: Tue, 28 Jun 2022 16:34:10 +0500 Subject: [PATCH] feat: Added flag for big blue button provider (#30645) * feat: added flag for big blue button provider * feat: Updated a comment * fix: updated tests * fix: updated serializer * fix: resolved failed tests Co-authored-by: AhtishamShahid --- .../core/djangoapps/course_live/config/waffle.py | 12 ++++++++++++ openedx/core/djangoapps/course_live/providers.py | 14 +++++++------- openedx/core/djangoapps/course_live/serializers.py | 4 ---- .../djangoapps/course_live/tests/test_views.py | 9 ++++++--- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/openedx/core/djangoapps/course_live/config/waffle.py b/openedx/core/djangoapps/course_live/config/waffle.py index f86a368bc0..9d4d7c5eda 100644 --- a/openedx/core/djangoapps/course_live/config/waffle.py +++ b/openedx/core/djangoapps/course_live/config/waffle.py @@ -17,3 +17,15 @@ WAFFLE_NAMESPACE = 'course_live' # .. 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 +# .. 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 4c0c0af4d4..c9917aee94 100644 --- a/openedx/core/djangoapps/course_live/providers.py +++ b/openedx/core/djangoapps/course_live/providers.py @@ -5,6 +5,8 @@ from abc import ABC 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): """ @@ -111,7 +113,7 @@ class BigBlueButton(LiveProvider, HasGlobalCredentials): @property def is_enabled(self) -> bool: - return True + return ENABLE_BIG_BLUE_BUTTON.is_enabled() @staticmethod def get_global_keys() -> Dict: @@ -129,12 +131,10 @@ class BigBlueButton(LiveProvider, HasGlobalCredentials): """ credentials = self.get_global_keys() if credentials: - self.key = credentials['KEY'] - self.secret = credentials['SECRET'] - self.url = credentials['URL'] - return bool(credentials.get("KEY", None) - and credentials.get("SECRET", None) - and credentials.get("URL", None)) + self.key = credentials.get('KEY') + self.secret = credentials.get('SECRET') + self.url = credentials.get('URL') + return bool(self.key and self.secret and self.url) return False diff --git a/openedx/core/djangoapps/course_live/serializers.py b/openedx/core/djangoapps/course_live/serializers.py index 9fa3405fac..67b449057f 100644 --- a/openedx/core/djangoapps/course_live/serializers.py +++ b/openedx/core/djangoapps/course_live/serializers.py @@ -7,10 +7,6 @@ from lti_consumer.models import LtiConfiguration from rest_framework import serializers from .models import CourseLiveConfiguration -# from .utils import provider_requires_custom_email -from .providers import ProviderManager - -providers = ProviderManager().get_enabled_providers() class LtiSerializer(serializers.ModelSerializer): diff --git a/openedx/core/djangoapps/course_live/tests/test_views.py b/openedx/core/djangoapps/course_live/tests/test_views.py index 6a67ab6634..b177cbad34 100644 --- a/openedx/core/djangoapps/course_live/tests/test_views.py +++ b/openedx/core/djangoapps/course_live/tests/test_views.py @@ -13,14 +13,13 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import CourseUserType, ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory -from ..config.waffle import ENABLE_COURSE_LIVE +from ..config.waffle import ENABLE_COURSE_LIVE, ENABLE_BIG_BLUE_BUTTON from ..models import CourseLiveConfiguration from ..providers import ProviderManager -providers = ProviderManager().get_enabled_providers() - @ddt.ddt +@override_waffle_flag(ENABLE_BIG_BLUE_BUTTON, True) class TestCourseLiveConfigurationView(ModuleStoreTestCase, APITestCase): """ Unit tests for the CourseLiveConfigurationView. @@ -50,6 +49,7 @@ class TestCourseLiveConfigurationView(ModuleStoreTestCase, APITestCase): """ creates a courseLiveConfiguration """ + providers = ProviderManager().get_enabled_providers() if providers.get(provider).requires_pii_sharing(): CourseAllowPIISharingInLTIFlag.objects.create(course_id=self.course.id, enabled=True) @@ -272,6 +272,7 @@ class TestCourseLiveConfigurationView(ModuleStoreTestCase, APITestCase): """ Create and test POST request response data """ + providers = ProviderManager().get_enabled_providers() if providers.get(provider).requires_pii_sharing(): CourseAllowPIISharingInLTIFlag.objects.create(course_id=self.course.id, enabled=True) @@ -307,6 +308,7 @@ class TestCourseLiveConfigurationView(ModuleStoreTestCase, APITestCase): self.assertEqual(content, expected_data) +@override_waffle_flag(ENABLE_BIG_BLUE_BUTTON, True) class TestCourseLiveProvidersView(ModuleStoreTestCase, APITestCase): """ Tests for course live provider view @@ -328,6 +330,7 @@ class TestCourseLiveProvidersView(ModuleStoreTestCase, APITestCase): ) def test_response_has_correct_data(self): + providers = ProviderManager().get_enabled_providers() expected_data = { 'providers': { 'active': '',