feat!: remove most Old Mongo functionality (#31134)

This commit leaves behind just enough Old Mongo (DraftModulestore)
functionality to allow read-only access to static assets and the
root CourseBlock. It removes:

* create/update operations
* child/parent traversal
* inheritance related code

It also removes or converts tests for this functionality.

The ability to read from the root CourseBlock was maintained for
backwards compatibility, since top-level course settings are often
stored here, and this is used by various parts of the codebase,
like displaying dashboards and re-building CourseOverview models.

Any attempt to read the contents of a course by getting the
CourseBlock's children will return an empty list (i.e. it will look
empty).

This commit does _not_ delete content on MongoDB or run any sort of
data migration or cleanup.
This commit is contained in:
Sagirov Evgeniy
2023-09-06 17:01:31 +03:00
committed by GitHub
parent a1d840fd09
commit c5d1807c81
40 changed files with 663 additions and 3146 deletions

View File

@@ -30,7 +30,6 @@ from xmodule.modulestore.tests.utils import (
)
_TODAY = datetime.now(utc)
_LAST_MONTH = _TODAY - timedelta(days=30)
_LAST_WEEK = _TODAY - timedelta(days=7)
_NEXT_WEEK = _TODAY + timedelta(days=7)
@@ -49,34 +48,9 @@ class CourseMetadataUtilsTestCase(TestCase):
mongo_builder = MongoModulestoreBuilder()
split_builder = VersioningModulestoreBuilder()
mixed_builder = MixedModulestoreBuilder([('mongo', mongo_builder), ('split', split_builder)])
mixed_builder = MixedModulestoreBuilder([('split', split_builder), ('mongo', mongo_builder)])
with mixed_builder.build_without_contentstore() as (__, mixed_store):
with mixed_store.default_store('mongo'):
self.demo_course = mixed_store.create_course(
org="edX",
course="DemoX.1",
run="Fall_2014",
user_id=-3, # -3 refers to a "testing user"
fields={
"start": _LAST_MONTH,
"end": _LAST_WEEK,
"enrollment_start": _LAST_MONTH,
"enrollment_end": _LAST_WEEK
}
)
with mixed_store.default_store('mongo'):
self.demo_course_enrollment_end = mixed_store.create_course(
org="edX",
course="DemoX.2",
run="Fall_2014_1",
user_id=-3, # -3 refers to a "testing user"
fields={
"start": _LAST_MONTH,
"end": _LAST_WEEK,
"enrollment_end": _LAST_WEEK
}
)
with mixed_store.default_store('split'):
self.html_course = mixed_store.create_course(
org="UniversityX",
@@ -145,11 +119,6 @@ class CourseMetadataUtilsTestCase(TestCase):
function_tests = [
FunctionTest(clean_course_key, [
# Test with a Mongo course and '=' as padding.
TestScenario(
(self.demo_course.id, '='),
"course_MVSFQL2EMVWW6WBOGEXUMYLMNRPTEMBRGQ======"
),
# Test with a Split course and '~' as padding.
TestScenario(
(self.html_course.id, '~'),
@@ -157,39 +126,26 @@ class CourseMetadataUtilsTestCase(TestCase):
),
]),
FunctionTest(url_name_for_block, [
TestScenario((self.demo_course,), self.demo_course.location.block_id),
TestScenario((self.html_course,), self.html_course.location.block_id),
]),
FunctionTest(display_name_with_default_escaped, [
# Test course with no display name.
TestScenario((self.demo_course,), "Empty"),
# Test course with a display name that contains characters that need escaping.
TestScenario((self.html_course,), "Intro to html"),
]),
FunctionTest(display_name_with_default, [
# Test course with no display name.
TestScenario((self.demo_course,), "Empty"),
# Test course with a display name that contains characters that need escaping.
TestScenario((self.html_course,), "Intro to <div>html</div>"),
]),
FunctionTest(number_for_course_location, [
TestScenario((self.demo_course.location,), "DemoX.1"),
TestScenario((self.html_course.location,), "CS-203"),
]),
FunctionTest(has_course_started, [
TestScenario((self.demo_course.start,), True),
TestScenario((self.html_course.start,), False),
]),
FunctionTest(has_course_ended, [
TestScenario((self.demo_course.end,), True),
TestScenario((self.html_course.end,), False),
]),
FunctionTest(is_enrollment_open, [
TestScenario((self.demo_course.enrollment_start, self.demo_course.enrollment_end,), False),
TestScenario((
self.demo_course_enrollment_end.enrollment_start,
self.demo_course_enrollment_end.enrollment_end
), False),
TestScenario((self.html_course.enrollment_start, self.html_course.enrollment_end,), False),
TestScenario((
self.html_course_enrollment_start.enrollment_start,