Files
edx-platform/lms/djangoapps/course_home_api/tests/utils.py
Michael Terry cb1bb7fa64 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.
2022-02-04 14:32:50 -05:00

59 lines
2.1 KiB
Python

"""
Base classes or util functions for use in Course Home API tests
"""
import unittest
from datetime import datetime
from django.conf import settings
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
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
from lms.djangoapps.courseware.tests.helpers import MasqueradeMixin
from lms.djangoapps.verify_student.models import VerificationDeadline
from openedx.core.djangoapps.content.course_overviews.tests.factories import CourseOverviewFactory
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class BaseCourseHomeTests(ModuleStoreTestCase, MasqueradeMixin):
"""
Base class for Course Home API tests.
Creates a course to
"""
def setUp(self):
super().setUp()
self.course = CourseFactory.create(
start=datetime(2020, 1, 1),
end=datetime(2028, 1, 1),
enrollment_start=datetime(2020, 1, 1),
enrollment_end=datetime(2028, 1, 1),
emit_signals=True,
modulestore=self.store,
)
chapter = ItemFactory(parent=self.course, category='chapter')
ItemFactory(parent=chapter, category='sequential')
CourseModeFactory(course_id=self.course.id, mode_slug=CourseMode.AUDIT)
CourseModeFactory(
course_id=self.course.id,
mode_slug=CourseMode.VERIFIED,
expiration_datetime=datetime(2028, 1, 1),
min_price=149,
sku='ABCD1234',
)
VerificationDeadline.objects.create(course_key=self.course.id, deadline=datetime(2028, 1, 1))
CourseOverviewFactory.create(run='1T2020')
self.staff_user = self.user
self.user, password = self.create_non_staff_user()
self.client.login(username=self.user.username, password=password)
def switch_to_staff(self):
self.user = self.staff_user
self.client.login(username=self.user.username, password=self.user_password)