test: switch default test store to the split store
It's long past time that the default test modulestore was Split, instead of Old Mongo. This commit switches the default store and fixes some tests that now fail: - Tests that didn't expect MFE to be enabled (because we don't enable MFE for Old Mongo) - opt out of MFE for those - Tests that hardcoded old key string formats - Lots of other random little differences In many places, I didn't spend much time trying to figure out how to properly fix the test, and instead just set the modulestore to Old Mongo. For those tests that I didn't spend time investigating, I've set the modulestore to TEST_DATA_MONGO_AMNESTY_MODULESTORE - search for that string to find further work.
This commit is contained in:
@@ -105,7 +105,8 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
|
||||
if redirect:
|
||||
if has_started:
|
||||
self.assertRedirects(
|
||||
response, reverse('openedx.course_experience.course_home', kwargs={'course_id': course.id})
|
||||
response, reverse('openedx.course_experience.course_home', kwargs={'course_id': course.id}),
|
||||
target_status_code=302, # for follow-on redirection to MFE (ideally we'd just be sent there first)
|
||||
)
|
||||
else:
|
||||
self.assertRedirects(response, reverse('dashboard'))
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestStudentDashboardEmailView(SharedModuleStoreTestCase):
|
||||
# URL for email settings modal
|
||||
self.email_modal_link = (
|
||||
'<a href="#email-settings-modal" class="action action-email-settings" rel="leanModal" '
|
||||
'data-course-id="{org}/{num}/{name}" data-course-number="{num}" '
|
||||
'data-course-id="course-v1:{org}+{num}+{name}" data-course-number="{num}" '
|
||||
'data-dashboard-index="0" data-optout="False">Email Settings</a>'
|
||||
).format(
|
||||
org=self.course.org,
|
||||
|
||||
@@ -10,6 +10,10 @@ from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from pytz import UTC
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.data import CertificatesDisplayBehaviors
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory
|
||||
@@ -19,10 +23,6 @@ from lms.djangoapps.certificates.tests.factories import (
|
||||
GeneratedCertificateFactory,
|
||||
LinkedInAddToProfileConfigurationFactory
|
||||
)
|
||||
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.data import CertificatesDisplayBehaviors # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
# pylint: disable=no-member
|
||||
|
||||
@@ -33,6 +33,7 @@ FUTURE_DATE = datetime.datetime.now(UTC) + datetime.timedelta(days=2)
|
||||
class CertificateDisplayTestBase(SharedModuleStoreTestCase):
|
||||
"""Tests display of certificates on the student dashboard. """
|
||||
|
||||
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
|
||||
USERNAME = "test_user"
|
||||
PASSWORD = "password"
|
||||
DOWNLOAD_URL = "http://www.example.com/certificate.pdf"
|
||||
|
||||
@@ -11,6 +11,8 @@ import pytest
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from openedx_events.tests.utils import OpenEdxEventsTestMixin
|
||||
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, SharedModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
|
||||
from common.djangoapps.course_modes.models import CourseMode
|
||||
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
|
||||
@@ -24,8 +26,6 @@ from common.djangoapps.student.roles import CourseInstructorRole, CourseStaffRol
|
||||
from common.djangoapps.student.tests.factories import CourseEnrollmentAllowedFactory, UserFactory
|
||||
from common.djangoapps.util.testing import UrlResetMixin
|
||||
from openedx.core.djangoapps.embargo.test_utils import restrict_course
|
||||
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@@ -36,6 +36,7 @@ class EnrollmentTest(UrlResetMixin, SharedModuleStoreTestCase, OpenEdxEventsTest
|
||||
Test student enrollment, especially with different course modes.
|
||||
"""
|
||||
|
||||
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
|
||||
ENABLED_OPENEDX_EVENTS = []
|
||||
|
||||
USERNAME = "Bob"
|
||||
|
||||
@@ -5,7 +5,6 @@ Test the student dashboard view.
|
||||
|
||||
import itertools
|
||||
import json
|
||||
import re
|
||||
import unittest
|
||||
from datetime import datetime, timedelta # lint-amnesty, pylint: disable=unused-import
|
||||
from unittest.mock import patch
|
||||
@@ -642,16 +641,13 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
return ''.join(response.content.decode('utf-8').split())
|
||||
|
||||
@staticmethod
|
||||
def _pull_course_run_from_course_key(course_key_string): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
search_results = re.search(r'Run_[0-9]+$', course_key_string)
|
||||
assert search_results
|
||||
course_run_string = search_results.group(0).replace('_', ' ')
|
||||
return course_run_string
|
||||
def _pull_course_run_from_course_key(course_key: CourseKey): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
return course_key.run.replace('_', ' ')
|
||||
|
||||
@staticmethod
|
||||
def _get_html_for_view_course_button(course_key_string, course_run_string):
|
||||
return '''
|
||||
<a href="/courses/{course_key}/course/"
|
||||
<a href="http://learning-mfe/course/{course_key}/home"
|
||||
class="course-target-link enter-course"
|
||||
data-course-key="{course_key}">
|
||||
View Course
|
||||
@@ -679,7 +675,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _get_html_for_entitlement_button(course_key_string):
|
||||
def _get_html_for_entitlement_button(course_key: CourseKey):
|
||||
return'''
|
||||
<div class="course-info">
|
||||
<span class="info-university">{org} - </span>
|
||||
@@ -689,8 +685,8 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
</span>
|
||||
</div>
|
||||
'''.format(
|
||||
org=course_key_string.split('/')[0],
|
||||
course=course_key_string.split('/')[1]
|
||||
org=course_key.org,
|
||||
course=course_key.course,
|
||||
)
|
||||
|
||||
def test_view_course_appears_on_dashboard(self):
|
||||
@@ -711,7 +707,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
course_key_string = str(course.id)
|
||||
# No completion data means there's no block from which to resume.
|
||||
resume_block_key_string = ''
|
||||
course_run_string = self._pull_course_run_from_course_key(course_key_string)
|
||||
course_run_string = self._pull_course_run_from_course_key(course.id)
|
||||
|
||||
view_button_html = self._get_html_for_view_course_button(
|
||||
course_key_string,
|
||||
@@ -759,7 +755,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
|
||||
course_key_string = str(course_key)
|
||||
resume_block_key_string = str(block_keys[-1])
|
||||
course_run_string = self._pull_course_run_from_course_key(course_key_string)
|
||||
course_run_string = self._pull_course_run_from_course_key(course_key)
|
||||
|
||||
view_button_html = self._get_html_for_view_course_button(
|
||||
course_key_string,
|
||||
@@ -840,8 +836,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
|
||||
else:
|
||||
last_completed_block_string = ''
|
||||
course_run_string = self._pull_course_run_from_course_key(
|
||||
course_key_string)
|
||||
course_run_string = self._pull_course_run_from_course_key(course_key)
|
||||
|
||||
# Submit completed course blocks in even-numbered courses.
|
||||
if isEven(i):
|
||||
@@ -871,9 +866,7 @@ class StudentDashboardTests(SharedModuleStoreTestCase, MilestonesTestCaseMixin,
|
||||
)
|
||||
)
|
||||
html_for_entitlement.append(
|
||||
self._get_html_for_entitlement_button(
|
||||
course_key_string
|
||||
)
|
||||
self._get_html_for_entitlement_button(course_key)
|
||||
)
|
||||
|
||||
response = self.client.get(reverse('dashboard'))
|
||||
|
||||
Reference in New Issue
Block a user