From 040f5cc9c441a4520d30930671a136550219506b Mon Sep 17 00:00:00 2001 From: John Eskew Date: Wed, 20 Sep 2017 20:30:43 -0400 Subject: [PATCH] Move edxnotes model import down into method. --- lms/djangoapps/edxnotes/decorators.py | 3 ++- lms/djangoapps/edxnotes/tests.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lms/djangoapps/edxnotes/decorators.py b/lms/djangoapps/edxnotes/decorators.py index 42857d7845..90b4257af1 100644 --- a/lms/djangoapps/edxnotes/decorators.py +++ b/lms/djangoapps/edxnotes/decorators.py @@ -7,7 +7,6 @@ import json from django.conf import settings from edxmako.shortcuts import render_to_string -from edxnotes.helpers import generate_uid, get_edxnotes_id_token, get_public_endpoint, get_token_url, is_feature_enabled def edxnotes(cls): @@ -20,6 +19,8 @@ def edxnotes(cls): """ Returns raw html for the component. """ + # Import is placed here to avoid model import at project startup. + from edxnotes.helpers import generate_uid, get_edxnotes_id_token, get_public_endpoint, get_token_url, is_feature_enabled is_studio = getattr(self.system, "is_author_mode", False) course = self.descriptor.runtime.modulestore.get_course(self.runtime.course_id) diff --git a/lms/djangoapps/edxnotes/tests.py b/lms/djangoapps/edxnotes/tests.py index dfc8e28139..d55c51e1f3 100644 --- a/lms/djangoapps/edxnotes/tests.py +++ b/lms/djangoapps/edxnotes/tests.py @@ -106,10 +106,10 @@ class EdxNotesDecoratorTest(ModuleStoreTestCase): self.problem = TestProblem(self.course) @patch.dict("django.conf.settings.FEATURES", {'ENABLE_EDXNOTES': True}) - @patch("edxnotes.decorators.get_public_endpoint", autospec=True) - @patch("edxnotes.decorators.get_token_url", autospec=True) - @patch("edxnotes.decorators.get_edxnotes_id_token", autospec=True) - @patch("edxnotes.decorators.generate_uid", autospec=True) + @patch("edxnotes.helpers.get_public_endpoint", autospec=True) + @patch("edxnotes.helpers.get_token_url", autospec=True) + @patch("edxnotes.helpers.get_edxnotes_id_token", autospec=True) + @patch("edxnotes.helpers.generate_uid", autospec=True) def test_edxnotes_enabled(self, mock_generate_uid, mock_get_id_token, mock_get_token_url, mock_get_endpoint): """ Tests if get_html is wrapped when feature flag is on and edxnotes are