Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [AXIMST-432] 500 error appears if user adds a Content Experiment #2502

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions cms/djangoapps/contentstore/views/tests/test_container_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
}
)

Expand Down
Loading