From 8807fd6d5820b3093ebcfdd7abf15628ad236da2 Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 16 Jul 2026 05:03:02 +0000 Subject: [PATCH 1/7] feat: enable edx-notes by default and add related tests --- conftest.py | 21 +++++++++++++++++++ .../course_apps/tests/test_notes_app.py | 6 ++++++ xmodule/modulestore/inheritance.py | 2 +- xmodule/tests/test_split_test_block.py | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 3fc522a9692c..d1fd3fcc8430 100644 --- a/conftest.py +++ b/conftest.py @@ -5,6 +5,7 @@ from unittest import TestCase import pytest +from django.conf import settings # Import hooks and fixture overrides from the cms package to # avoid duplicating the implementation @@ -15,3 +16,23 @@ # 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(db): + """ + Create edx-notes OAuth2 Application for all tests when + ENABLE_EDXNOTES is enabled and the setting is configured. + """ + 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 + from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationFactory + + if not Application.objects.filter(name=client_name).exists(): + ApplicationFactory(name=client_name) 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. From 8dd0d80ed15ef555c4732bfe69fe9f56147012bd Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 16 Jul 2026 05:31:25 +0000 Subject: [PATCH 2/7] fix: update edx-notes OAuth2 client creation to avoid extra User creation --- conftest.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index d1fd3fcc8430..f8076eae3e5d 100644 --- a/conftest.py +++ b/conftest.py @@ -23,6 +23,9 @@ def create_edxnotes_oauth_client(db): """ Create edx-notes OAuth2 Application for all tests when ENABLE_EDXNOTES is enabled and the setting is configured. + + Uses direct model creation to avoid creating an extra User + (which breaks tests that count users or look them up by unique fields). """ client_name = getattr(settings, 'EDXNOTES_CLIENT_NAME', None) if not client_name: @@ -32,7 +35,11 @@ def create_edxnotes_oauth_client(db): return from oauth2_provider.models import Application - from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationFactory if not Application.objects.filter(name=client_name).exists(): - ApplicationFactory(name=client_name) + Application.objects.create( + name=client_name, + user=None, + client_type=Application.CLIENT_CONFIDENTIAL, + authorization_grant_type=Application.GRANT_CLIENT_CREDENTIALS, + ) From e1104b5fabd146113d9165bc558e841eb1eb7491 Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 16 Jul 2026 06:02:51 +0000 Subject: [PATCH 3/7] refactor: update create_edxnotes_oauth_client fixture to improve DB access handling --- conftest.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/conftest.py b/conftest.py index f8076eae3e5d..b520d21f088c 100644 --- a/conftest.py +++ b/conftest.py @@ -5,7 +5,6 @@ from unittest import TestCase import pytest -from django.conf import settings # Import hooks and fixture overrides from the cms package to # avoid duplicating the implementation @@ -19,14 +18,20 @@ @pytest.fixture(autouse=True) -def create_edxnotes_oauth_client(db): +def create_edxnotes_oauth_client(request): """ - Create edx-notes OAuth2 Application for all tests when - ENABLE_EDXNOTES is enabled and the setting is configured. - - Uses direct model creation to avoid creating an extra User - (which breaks tests that count users or look them up by unique fields). + Create edx-notes OAuth2 Application for tests that have DB access + when ENABLE_EDXNOTES is enabled. """ + from django.test import SimpleTestCase, TestCase as DjangoTestCase + + # Only run for tests with DB access. + if request.cls: + if issubclass(request.cls, SimpleTestCase) and not issubclass(request.cls, DjangoTestCase): + return + + from django.conf import settings + client_name = getattr(settings, 'EDXNOTES_CLIENT_NAME', None) if not client_name: return From ffa1ba2a0d02e1704e4d404548c3c0a52c8a84c4 Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 16 Jul 2026 06:24:37 +0000 Subject: [PATCH 4/7] fix: restrict edx-notes OAuth2 client creation to TransactionTestCase only --- conftest.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/conftest.py b/conftest.py index b520d21f088c..0b3750691df0 100644 --- a/conftest.py +++ b/conftest.py @@ -23,12 +23,13 @@ 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 SimpleTestCase, TestCase as DjangoTestCase + from django.test import TransactionTestCase - # Only run for tests with DB access. - if request.cls: - if issubclass(request.cls, SimpleTestCase) and not issubclass(request.cls, DjangoTestCase): - return + # Only run for Django class-based tests with DB access. + if not request.cls: + return + if not issubclass(request.cls, TransactionTestCase): + return from django.conf import settings From 94b103a1c65b86d87ed2fce6dced9b86ee79575c Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 16 Jul 2026 07:05:16 +0000 Subject: [PATCH 5/7] fix: skip edxnotes tests in OAuth2 client creation fixture --- conftest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conftest.py b/conftest.py index 0b3750691df0..f1bcb2c66d08 100644 --- a/conftest.py +++ b/conftest.py @@ -31,6 +31,10 @@ def create_edxnotes_oauth_client(request): 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) From 9a0ca4367c2dbe321f76ae7ca8866eac11dd3893 Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 16 Jul 2026 09:11:40 +0000 Subject: [PATCH 6/7] fix: comment out ENABLE_EDXNOTES patch in split test block tests --- xmodule/tests/test_split_test_block.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmodule/tests/test_split_test_block.py b/xmodule/tests/test_split_test_block.py index 6cca4701b18b..68b252c67c40 100644 --- a/xmodule/tests/test_split_test_block.py +++ b/xmodule/tests/test_split_test_block.py @@ -123,7 +123,7 @@ def setUp(self): self.split_test_block.runtime.modulestore = mocked_modulestore -@patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) +# @patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) @ddt.ddt class SplitTestBlockLMSTest(SplitTestBlockTest): """ @@ -187,7 +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}) +# @patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) class SplitTestBlockStudioTest(SplitTestBlockTest): """ Unit tests for how split test interacts with Studio. From d271d8de516abc90fa51247e3b6b1e36a6e4b683 Mon Sep 17 00:00:00 2001 From: alenkadev Date: Thu, 16 Jul 2026 09:22:00 +0000 Subject: [PATCH 7/7] fix: uncomment ENABLE_EDXNOTES patch in split test block tests --- xmodule/tests/test_split_test_block.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmodule/tests/test_split_test_block.py b/xmodule/tests/test_split_test_block.py index 68b252c67c40..6cca4701b18b 100644 --- a/xmodule/tests/test_split_test_block.py +++ b/xmodule/tests/test_split_test_block.py @@ -123,7 +123,7 @@ def setUp(self): self.split_test_block.runtime.modulestore = mocked_modulestore -# @patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) @ddt.ddt class SplitTestBlockLMSTest(SplitTestBlockTest): """ @@ -187,7 +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}) +@patch.dict("django.conf.settings.FEATURES", {"ENABLE_EDXNOTES": False}) class SplitTestBlockStudioTest(SplitTestBlockTest): """ Unit tests for how split test interacts with Studio.