Commit d7d6afe8 by chrisndodge

Merge pull request #28 from edx/cdodge/punchlist2

expose a is_feature_enabled() method
parents 34cd882f f004c530
......@@ -35,6 +35,14 @@ from edx_proctoring.utils import humanized_time
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,
is_proctored=True, external_id=None, is_active=True):
"""
......
......@@ -2,6 +2,7 @@
All tests for the models.py
"""
from datetime import datetime
from mock import patch
import pytz
......@@ -24,7 +25,9 @@ from edx_proctoring.api import (
get_exam_attempt_by_id,
remove_exam_attempt_by_id,
get_all_exam_attempts,
get_filtered_exam_attempts)
get_filtered_exam_attempts,
is_feature_enabled,
)
from edx_proctoring.exceptions import (
ProctoredExamAlreadyExists,
ProctoredExamNotFoundException,
......@@ -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
)
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):
"""
Test to create a proctored exam that has already exist in the
......
......@@ -17,6 +17,7 @@ USE_TZ = True
TIME_ZONE = {}
SECRET_KEY='SHHHHHH'
PLATFORM_NAME='Open edX'
FEATURES = {}
DATABASES = {
'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