diff --git a/cms/djangoapps/contentstore/views/tests/test_container_page.py b/cms/djangoapps/contentstore/views/tests/test_container_page.py index 2f5183e086a5..21e9a1b2763a 100644 --- a/cms/djangoapps/contentstore/views/tests/test_container_page.py +++ b/cms/djangoapps/contentstore/views/tests/test_container_page.py @@ -14,18 +14,15 @@ from urllib.parse import quote import cms.djangoapps.contentstore.views.component as views -from common.djangoapps.xblock_django.user_service import DjangoXBlockUserService from cms.djangoapps.contentstore.tests.test_libraries import LibraryTestCase from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID, UserPartition -from xmodule.partitions.tests.test_partitions import PartitionTestCase from .utils import StudioPageTestCase -class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase, PartitionTestCase): +class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase): """ Unit tests for the container page. """ @@ -37,24 +34,14 @@ def setUp(self): super().setUp() self.vertical = self._create_block(self.sequential, 'vertical', 'Unit') self.html = self._create_block(self.vertical, "html", "HTML") - self.user_partition = UserPartition( - ENROLLMENT_TRACK_PARTITION_ID, - self.TEST_NAME, - self.TEST_DESCRIPTION, - self.TEST_GROUPS - ) self.child_container = self._create_block( self.vertical, 'split_test', 'Split Test', - user_partition_id=ENROLLMENT_TRACK_PARTITION_ID, - user_partitions=[self.user_partition] ) self.child_vertical = self._create_block(self.child_container, 'vertical', 'Child Vertical') self.video = self._create_block(self.child_vertical, "video", "My Video") self.store = modulestore() - user_service = DjangoXBlockUserService(self.user) - self.child_container.runtime._services['user'] = user_service # pylint: disable=protected-access past = datetime.datetime(1970, 1, 1, tzinfo=UTC) future = datetime.datetime.now(UTC) + datetime.timedelta(days=1) diff --git a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py index eb4438a5b1d8..9788c34cc2d4 100644 --- a/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py +++ b/cms/djangoapps/contentstore/xblock_storage_handlers/view_handlers.py @@ -88,6 +88,11 @@ CREATE_IF_NOT_FOUND = ["course_info"] +# List of categories to check for presence in the children of the XBlock. +# This list is used to determine if all of the specified categories are absent +# in the categories of the children XBlock instances otherwise icon class variable will be set to `None`. +CATEGORIES_WITH_ABSENT_ICON = ["split_test"] + # Useful constants for defining predicates NEVER = lambda x: False ALWAYS = lambda x: True @@ -1064,6 +1069,10 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements ) else: user_partitions = get_user_partition_info(xblock, course=course) + all_excluded_categories_absent = all( + category not in [child.category for child in xblock.get_children()] + for category in CATEGORIES_WITH_ABSENT_ICON + ) xblock_info.update( { "edited_on": get_default_time_display(xblock.subtree_edited_on) @@ -1091,7 +1100,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements "group_access": xblock.group_access, "user_partitions": user_partitions, "show_correctness": xblock.show_correctness, - "xblock_type": get_icon(xblock) if is_xblock_unit else None, + "xblock_type": get_icon(xblock) if is_xblock_unit and all_excluded_categories_absent else None, } )