diff --git a/conftest.py b/conftest.py index 3fc522a9692c..f1bcb2c66d08 100644 --- a/conftest.py +++ b/conftest.py @@ -15,3 +15,41 @@ # When using self.assertEquals, diffs are truncated. We don't want that, always # show the whole diff. TestCase.maxDiff = None + + +@pytest.fixture(autouse=True) +def create_edxnotes_oauth_client(request): + """ + Create edx-notes OAuth2 Application for tests that have DB access + when ENABLE_EDXNOTES is enabled. + """ + from django.test import TransactionTestCase + + # Only run for Django class-based tests with DB access. + if not request.cls: + return + if not issubclass(request.cls, TransactionTestCase): + return + + # Skip for edxnotes tests; they create their own Application. + if 'edxnotes' in request.node.module.__name__: + return + + from django.conf import settings + + client_name = getattr(settings, 'EDXNOTES_CLIENT_NAME', None) + if not client_name: + return + + if not getattr(settings, 'FEATURES', {}).get('ENABLE_EDXNOTES', False): + return + + from oauth2_provider.models import Application + + if not Application.objects.filter(name=client_name).exists(): + Application.objects.create( + name=client_name, + user=None, + client_type=Application.CLIENT_CONFIDENTIAL, + authorization_grant_type=Application.GRANT_CLIENT_CREDENTIALS, + ) diff --git a/openedx/core/djangoapps/course_apps/tests/test_notes_app.py b/openedx/core/djangoapps/course_apps/tests/test_notes_app.py index db2d3563b821..c8c677125b51 100644 --- a/openedx/core/djangoapps/course_apps/tests/test_notes_app.py +++ b/openedx/core/djangoapps/course_apps/tests/test_notes_app.py @@ -19,6 +19,12 @@ class NotesCourseAppTestCase(TabBasedCourseAppTestMixin, ModuleStoreTestCase): tab_type = 'edxnotes' course_app_class = EdxNotesCourseApp + def test_app_disabled_by_default(self): + """ + Override base mixin behavior: Notes is enabled by default. + """ + assert self.course_app_class.is_enabled(self.course.id) + def _assert_app_enabled(self, app_tab): assert app_tab.is_enabled(self.course, self.user) diff --git a/xmodule/modulestore/inheritance.py b/xmodule/modulestore/inheritance.py index 4c5a14b769cb..f34256777c46 100644 --- a/xmodule/modulestore/inheritance.py +++ b/xmodule/modulestore/inheritance.py @@ -210,7 +210,7 @@ class InheritanceMixin(XBlockMixin): edxnotes = Boolean( display_name=_("Enable Student Notes"), help=_("Enter true or false. If true, students can use the Student Notes feature."), - default=False, + default=True, scope=Scope.settings ) edxnotes_visibility = Boolean( diff --git a/xmodule/tests/test_split_test_block.py b/xmodule/tests/test_split_test_block.py index c51c157a7760..6cca4701b18b 100644 --- a/xmodule/tests/test_split_test_block.py +++ b/xmodule/tests/test_split_test_block.py @@ -123,6 +123,7 @@ def setUp(self): self.split_test_block.runtime.modulestore = mocked_modulestore +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) @ddt.ddt class SplitTestBlockLMSTest(SplitTestBlockTest): """ @@ -186,6 +187,7 @@ def test_export_import_round_trip(self, def_to_xml): assert len(children) == 2 +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) class SplitTestBlockStudioTest(SplitTestBlockTest): """ Unit tests for how split test interacts with Studio.