Commit f004c530 by Chris Dodge

expose a is_feature_enabled() method

parent 34cd882f
...@@ -35,6 +35,14 @@ from edx_proctoring.utils import humanized_time ...@@ -35,6 +35,14 @@ from edx_proctoring.utils import humanized_time
from edx_proctoring.backends import get_backend_provider from edx_proctoring.backends import get_backend_provider
def is_feature_enabled():
"""
Returns if this feature has been enabled in our FEATURE flags
"""
return hasattr(settings, 'FEATURES') and settings.FEATURES.get('ENABLE_PROCTORED_EXAMS', False)
def create_exam(course_id, content_id, exam_name, time_limit_mins, def create_exam(course_id, content_id, exam_name, time_limit_mins,
is_proctored=True, external_id=None, is_active=True): is_proctored=True, external_id=None, is_active=True):
""" """
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
All tests for the models.py All tests for the models.py
""" """
from datetime import datetime from datetime import datetime
from mock import patch
import pytz import pytz
...@@ -24,7 +25,9 @@ from edx_proctoring.api import ( ...@@ -24,7 +25,9 @@ from edx_proctoring.api import (
get_exam_attempt_by_id, get_exam_attempt_by_id,
remove_exam_attempt_by_id, remove_exam_attempt_by_id,
get_all_exam_attempts, get_all_exam_attempts,
get_filtered_exam_attempts) get_filtered_exam_attempts,
is_feature_enabled,
)
from edx_proctoring.exceptions import ( from edx_proctoring.exceptions import (
ProctoredExamAlreadyExists, ProctoredExamAlreadyExists,
ProctoredExamNotFoundException, ProctoredExamNotFoundException,
...@@ -126,6 +129,18 @@ class ProctoredExamApiTests(LoggedInTestCase): ...@@ -126,6 +129,18 @@ class ProctoredExamApiTests(LoggedInTestCase):
proctored_exam_id=self.proctored_exam_id, user_id=self.user_id, key=self.key, value=self.value proctored_exam_id=self.proctored_exam_id, user_id=self.user_id, key=self.key, value=self.value
) )
def test_feature_enabled(self):
"""
Checks the is_feature_enabled method
"""
self.assertFalse(is_feature_enabled())
with patch.dict('django.conf.settings.FEATURES', {'ENABLE_PROCTORED_EXAMS': False}):
self.assertFalse(is_feature_enabled())
with patch.dict('django.conf.settings.FEATURES', {'ENABLE_PROCTORED_EXAMS': True}):
self.assertTrue(is_feature_enabled())
def test_create_duplicate_exam(self): def test_create_duplicate_exam(self):
""" """
Test to create a proctored exam that has already exist in the Test to create a proctored exam that has already exist in the
......
...@@ -17,6 +17,7 @@ USE_TZ = True ...@@ -17,6 +17,7 @@ USE_TZ = True
TIME_ZONE = {} TIME_ZONE = {}
SECRET_KEY='SHHHHHH' SECRET_KEY='SHHHHHH'
PLATFORM_NAME='Open edX' PLATFORM_NAME='Open edX'
FEATURES = {}
DATABASES = { DATABASES = {
'default': { 'default': {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment