Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +20 to +24
"""
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
Comment on lines +28 to +32

# 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,
)
Comment on lines +49 to +55
6 changes: 6 additions & 0 deletions openedx/core/djangoapps/course_apps/tests/test_notes_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +22 to +26
Comment on lines +22 to +26
Comment on lines +22 to +26
Comment on lines +22 to +26
Comment on lines +22 to +26
Comment on lines +22 to +26
Comment on lines +22 to +26
Comment on lines +22 to +26
Comment on lines +22 to +26

Comment on lines +22 to +27
Comment on lines +22 to +27
Comment on lines +22 to +27
Comment on lines +22 to +27
def _assert_app_enabled(self, app_tab):
assert app_tab.is_enabled(self.course, self.user)

Expand Down
2 changes: 1 addition & 1 deletion xmodule/modulestore/inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
Comment on lines 210 to 214
)
Comment on lines 210 to 215
Comment on lines 210 to 215
edxnotes_visibility = Boolean(
Expand Down
2 changes: 2 additions & 0 deletions xmodule/tests/test_split_test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.
Expand Down
Loading