test: tests for removing support for children in Old Mongo

* updated test_authoring_mixin.py
* updated test_xblock_utils.py
* updated TestOnboardingView tests (update default course key)
* updated UsersDefaultRole tests
This commit is contained in:
Sagirov Eugeniy
2022-12-19 15:56:43 +02:00
committed by David Ormsbee
parent 1c664bc121
commit f3de63058c
4 changed files with 33 additions and 36 deletions

View File

@@ -3,7 +3,9 @@ Unit tests for checking default forum role "Student" of a user when he creates a
after deleting it creates same course again
"""
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, ModuleStoreTestCase
from unittest import skip
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase
from cms.djangoapps.contentstore.tests.utils import AjaxEnabledTestClient
from cms.djangoapps.contentstore.utils import delete_course, reverse_url
@@ -15,7 +17,7 @@ class TestUsersDefaultRole(ModuleStoreTestCase):
"""
Unit tests for checking enrollment and default forum role "Student" of a logged in user
"""
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
def setUp(self):
"""
@@ -92,6 +94,8 @@ class TestUsersDefaultRole(ModuleStoreTestCase):
# check that user has his default "Student" forum role for this course
self.assertTrue(self.user.roles.filter(name="Student", course_id=self.course_key))
@skip("OldMongo Deprecation")
# Issue with case-insensitive course keys
def test_user_role_on_course_recreate_with_change_name_case(self):
"""
Test that creating same course again with different name case after deleting it gives user

View File

@@ -6,7 +6,7 @@ Tests for the Studio authoring XBlock mixin.
from django.conf import settings
from django.test.utils import override_settings
from xblock.core import XBlock
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, ModuleStoreTestCase
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.partitions.partitions import (
ENROLLMENT_TRACK_PARTITION_ID,
@@ -23,7 +23,7 @@ class AuthoringMixinTestCase(ModuleStoreTestCase):
"""
Tests the studio authoring XBlock mixin.
"""
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
GROUP_NO_LONGER_EXISTS = "This group no longer exists"
NO_CONTENT_OR_ENROLLMENT_GROUPS = "Access to this component is not restricted"
NO_CONTENT_ENROLLMENT_TRACK_ENABLED = "You can restrict access to this component to learners in specific enrollment tracks or content groups" # lint-amnesty, pylint: disable=line-too-long
@@ -44,27 +44,27 @@ class AuthoringMixinTestCase(ModuleStoreTestCase):
self.course = CourseFactory.create()
chapter = ItemFactory.create(
category='chapter',
parent_location=self.course.location,
parent=self.course,
display_name='Test Chapter'
)
sequential = ItemFactory.create(
category='sequential',
parent_location=chapter.location,
parent=chapter,
display_name='Test Sequential'
)
vertical = ItemFactory.create(
category='vertical',
parent_location=sequential.location,
parent=sequential,
display_name='Test Vertical'
)
video = ItemFactory.create(
category='video',
parent_location=vertical.location,
parent=vertical,
display_name='Test Vertical'
)
pure = ItemFactory.create(
category='pure',
parent_location=vertical.location,
parent=vertical,
display_name='Test Pure'
)
self.vertical_location = vertical.location

View File

@@ -31,7 +31,7 @@ from pytz import UTC
from rest_framework import status
from social_django.models import UserSocialAuth
from xmodule.modulestore.tests.django_utils import (
TEST_DATA_MONGO_AMNESTY_MODULESTORE, ModuleStoreTestCase, SharedModuleStoreTestCase,
TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase, SharedModuleStoreTestCase,
)
from xmodule.modulestore.tests.factories import CourseFactory
@@ -267,7 +267,7 @@ class SupportViewCertificatesTests(SupportViewTestCase):
"""
Tests for the certificates support view.
"""
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
def setUp(self):
"""Make the user support staff. """
@@ -290,7 +290,9 @@ class SupportViewCertificatesTests(SupportViewTestCase):
url = reverse("support:certificates") + "?user=student@example.com&course_id=" + quote(str(self.course.id))
response = self.client.get(url)
self.assertContains(response, "userFilter: 'student@example.com'")
self.assertContains(response, "courseFilter: '" + str(self.course.id) + "'")
# use replase due to escaping course id:
# https://docs.djangoproject.com/en/dev/ref/templates/builtins/#escapejs
self.assertContains(response, "courseFilter: '" + str(self.course.id).replace('-', '\\u002D') + "'")
@ddt.ddt
@@ -1859,12 +1861,15 @@ class TestOnboardingView(SupportViewTestCase, ProctoredExamTestCase):
"""
Tests for OnboardingView
"""
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
def setUp(self):
super().setUp()
SupportStaffRole().add_users(self.user)
# update default course key
self.course_id = 'course-v1:a+b+c'
self.proctored_exam_id = self._create_proctored_exam()
self.onboarding_exam_id = self._create_onboarding_exam()
@@ -1904,7 +1909,7 @@ class TestOnboardingView(SupportViewTestCase, ProctoredExamTestCase):
def _create_enrollment(self):
""" Create enrollment in default course """
# default course key = 'a/b/c'
# updated course key = 'course-v1:a+b+c'
self.course = CourseFactory.create(
org='a',
course='b',
@@ -2024,7 +2029,7 @@ class TestOnboardingView(SupportViewTestCase, ProctoredExamTestCase):
update_attempt_status(attempt_id, ProctoredExamStudentAttemptStatus.submitted)
# Create an attempt in the other course that has been verified
other_course_id = 'x/y/z'
other_course_id = 'course-v1:x+y+z'
other_course_onboarding_exam = ProctoredExam.objects.create(
course_id=other_course_id,
content_id=self.other_course_content,
@@ -2057,8 +2062,8 @@ class TestOnboardingView(SupportViewTestCase, ProctoredExamTestCase):
# assert that originally verified enrollment is reflected correctly
self.assertEqual(response_data['verified_in']['onboarding_status'], 'verified')
self.assertEqual(response_data['verified_in']['course_id'], 'x/y/z')
self.assertEqual(response_data['verified_in']['course_id'], other_course_id)
# assert that most recent enrollment (current status) has other_course_approved status
self.assertEqual(response_data['current_status']['onboarding_status'], 'other_course_approved')
self.assertEqual(response_data['current_status']['course_id'], 'a/b/c')
self.assertEqual(response_data['current_status']['course_id'], self.course_id)

View File

@@ -13,7 +13,7 @@ from opaque_keys.edx.asides import AsideUsageKeyV1, AsideUsageKeyV2
from web_fragments.fragment import Fragment
from xblock.core import XBlockAside
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, SharedModuleStoreTestCase
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore.tests.test_asides import AsideTestType
@@ -38,13 +38,7 @@ class TestXblockUtils(SharedModuleStoreTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.course_mongo = CourseFactory.create(
default_store=ModuleStoreEnum.Type.mongo,
org='TestX',
number='TS01',
run='2015'
)
cls.course_split = CourseFactory.create(
cls.course = CourseFactory.create(
default_store=ModuleStoreEnum.Type.split,
org='TestX',
number='TS02',
@@ -86,21 +80,15 @@ class TestXblockUtils(SharedModuleStoreTestCase):
test_uuid = uuid.UUID(token, version=1)
assert token == test_uuid.hex
@ddt.data(
('course_mongo', 'data-usage-id="i4x:;_;_TestX;_TS01;_course;_2015"'),
('course_split', 'data-usage-id="block-v1:TestX+TS02+2015+type@course+block@course"')
)
@ddt.unpack
def test_wrap_xblock(self, course_id, data_usage_id):
def test_wrap_xblock(self):
"""
Verify that new content is added and the resources are the same.
"""
fragment = self.create_fragment("<h1>Test!</h1>")
fragment.initialize_js('BlockMain') # wrap_block() sets some attributes only if there is JS.
course = getattr(self, course_id)
test_wrap_output = wrap_xblock(
runtime_class='TestRuntime',
block=course,
block=self.course,
view='baseview',
frag=fragment,
context={"wrap_xblock_data": {"custom-attribute": "custom-value"}},
@@ -110,7 +98,7 @@ class TestXblockUtils(SharedModuleStoreTestCase):
assert isinstance(test_wrap_output, Fragment)
assert 'xblock-baseview' in test_wrap_output.content
assert 'data-runtime-class="TestRuntime"' in test_wrap_output.content
assert data_usage_id in test_wrap_output.content
assert 'data-usage-id="block-v1:TestX+TS02+2015+type@course+block@course"' in test_wrap_output.content
assert '<h1>Test!</h1>' in test_wrap_output.content
assert 'data-custom-attribute="custom-value"' in test_wrap_output.content
assert test_wrap_output.resources[0].data == 'body {background-color:red;}'
@@ -170,13 +158,13 @@ class TestXblockUtils(SharedModuleStoreTestCase):
class TestXBlockAside(SharedModuleStoreTestCase):
"""Test the xblock aside function."""
MODULESTORE = TEST_DATA_MONGO_AMNESTY_MODULESTORE
MODULESTORE = TEST_DATA_SPLIT_MODULESTORE
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.course = CourseFactory.create()
cls.block = ItemFactory.create(category='aside', parent=cls.course)
cls.block = ItemFactory.create(parent=cls.course)
cls.aside_v2 = AsideUsageKeyV2(cls.block.scope_ids.usage_id, "aside")
cls.aside_v1 = AsideUsageKeyV1(cls.block.scope_ids.usage_id, "aside")