-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
40 changed files
with
667 additions
and
3,150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
|
||
from io import StringIO | ||
|
||
import ddt | ||
from django.core.management import CommandError, call_command | ||
from django.test import TestCase | ||
|
||
|
@@ -40,27 +39,28 @@ def test_nonexistent_user_email(self): | |
call_command('create_course', "mongo", "[email protected]", "org", "course", "run") | ||
|
||
|
||
@ddt.ddt | ||
class TestCreateCourse(ModuleStoreTestCase): | ||
""" | ||
Unit tests for creating a course in either old mongo or split mongo via command line | ||
""" | ||
|
||
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) | ||
def test_all_stores_user_email(self, store): | ||
def test_all_stores_user_email(self): | ||
call_command( | ||
"create_course", | ||
store, | ||
ModuleStoreEnum.Type.split, | ||
str(self.user.email), | ||
"org", "course", "run", "dummy-course-name" | ||
) | ||
new_key = modulestore().make_course_key("org", "course", "run") | ||
self.assertTrue( | ||
modulestore().has_course(new_key), | ||
f"Could not find course in {store}" | ||
f"Could not find course in {ModuleStoreEnum.Type.split}" | ||
) | ||
# pylint: disable=protected-access | ||
self.assertEqual(store, modulestore()._get_modulestore_for_courselike(new_key).get_modulestore_type()) | ||
self.assertEqual( | ||
ModuleStoreEnum.Type.split, | ||
modulestore()._get_modulestore_for_courselike(new_key).get_modulestore_type() | ||
) | ||
|
||
def test_duplicate_course(self): | ||
""" | ||
|
@@ -85,8 +85,7 @@ def test_duplicate_course(self): | |
expected = "Course already exists" | ||
self.assertIn(out.getvalue().strip(), expected) | ||
|
||
@ddt.data(ModuleStoreEnum.Type.split, ModuleStoreEnum.Type.mongo) | ||
def test_get_course_with_different_case(self, default_store): | ||
def test_get_course_with_different_case(self): | ||
""" | ||
Tests that course can not be accessed with different case. | ||
|
@@ -98,21 +97,20 @@ def test_get_course_with_different_case(self, default_store): | |
org = 'org1' | ||
number = 'course1' | ||
run = 'run1' | ||
with self.store.default_store(default_store): | ||
lowercase_course_id = self.store.make_course_key(org, number, run) | ||
with self.store.bulk_operations(lowercase_course_id, ignore_case=True): | ||
# Create course with lowercase key & Verify that store returns course. | ||
self.store.create_course( | ||
lowercase_course_id.org, | ||
lowercase_course_id.course, | ||
lowercase_course_id.run, | ||
self.user.id | ||
) | ||
course = self.store.get_course(lowercase_course_id) | ||
self.assertIsNotNone(course, 'Course not found using lowercase course key.') | ||
self.assertEqual(str(course.id), str(lowercase_course_id)) | ||
|
||
# Verify store does not return course with different case. | ||
uppercase_course_id = self.store.make_course_key(org.upper(), number.upper(), run.upper()) | ||
course = self.store.get_course(uppercase_course_id) | ||
self.assertIsNone(course, 'Course should not be accessed with uppercase course id.') | ||
lowercase_course_id = self.store.make_course_key(org, number, run) | ||
with self.store.bulk_operations(lowercase_course_id, ignore_case=True): | ||
# Create course with lowercase key & Verify that store returns course. | ||
self.store.create_course( | ||
lowercase_course_id.org, | ||
lowercase_course_id.course, | ||
lowercase_course_id.run, | ||
self.user.id | ||
) | ||
course = self.store.get_course(lowercase_course_id) | ||
self.assertIsNotNone(course, 'Course not found using lowercase course key.') | ||
self.assertEqual(str(course.id), str(lowercase_course_id)) | ||
|
||
# Verify store does not return course with different case. | ||
uppercase_course_id = self.store.make_course_key(org.upper(), number.upper(), run.upper()) | ||
course = self.store.get_course(uppercase_course_id) | ||
self.assertIsNone(course, 'Course should not be accessed with uppercase course id.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.