diff --git a/cms/djangoapps/contentstore/api/tests/base.py b/cms/djangoapps/contentstore/api/tests/base.py index 2da577e975ee..a169c431e419 100644 --- a/cms/djangoapps/contentstore/api/tests/base.py +++ b/cms/djangoapps/contentstore/api/tests/base.py @@ -6,7 +6,7 @@ from django.urls import reverse from rest_framework.test import APITestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import StaffFactory from common.djangoapps.student.tests.factories import UserFactory @@ -40,44 +40,44 @@ def initialize_course(cls, course): course.self_paced = True cls.store.update_item(course, cls.staff.id) - cls.section = ItemFactory.create( + cls.section = BlockFactory.create( parent_location=course.location, category="chapter", ) - cls.subsection1 = ItemFactory.create( + cls.subsection1 = BlockFactory.create( parent_location=cls.section.location, category="sequential", ) - unit1 = ItemFactory.create( + unit1 = BlockFactory.create( parent_location=cls.subsection1.location, category="vertical", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit1.location, category="video", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit1.location, category="problem", ) - cls.subsection2 = ItemFactory.create( + cls.subsection2 = BlockFactory.create( parent_location=cls.section.location, category="sequential", ) - unit2 = ItemFactory.create( + unit2 = BlockFactory.create( parent_location=cls.subsection2.location, category="vertical", ) - unit3 = ItemFactory.create( + unit3 = BlockFactory.create( parent_location=cls.subsection2.location, category="vertical", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit3.location, category="video", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit3.location, category="video", ) diff --git a/cms/djangoapps/contentstore/api/tests/test_validation.py b/cms/djangoapps/contentstore/api/tests/test_validation.py index 5c0424d706eb..4b94c3558822 100644 --- a/cms/djangoapps/contentstore/api/tests/test_validation.py +++ b/cms/djangoapps/contentstore/api/tests/test_validation.py @@ -10,7 +10,7 @@ from rest_framework import status from rest_framework.test import APITestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import StaffFactory from common.djangoapps.student.tests.factories import UserFactory @@ -57,11 +57,11 @@ def initialize_course(cls, course): fields=dict(data="
'
self.course_link = 'Test course rewrite'
- self.descriptor = ItemFactory.create(
+ self.descriptor = BlockFactory.create(
category='html',
data=self.content_string + self.rewrite_link + self.rewrite_bad_link + self.course_link
)
@@ -1649,7 +1649,7 @@ def test_json_init_data(self, json_data, json_output):
mock_request = MagicMock()
mock_request.user = mock_user
course = CourseFactory()
- descriptor = ItemFactory(category='withjson', parent=course)
+ descriptor = BlockFactory(category='withjson', parent=course)
field_data_cache = FieldDataCache([course, descriptor], course.id, mock_user)
module = render.get_module_for_descriptor(
mock_user,
@@ -1704,7 +1704,7 @@ def setUp(self):
options=['Correct', 'Incorrect'],
correct_option='Correct'
)
- self.descriptor = ItemFactory.create(
+ self.descriptor = BlockFactory.create(
category='problem',
data=problem_xml,
display_name='Option Response Problem'
@@ -1757,7 +1757,7 @@ def test_staff_debug_info_score_for_invalid_dropdown(self):
"""
- problem_descriptor = ItemFactory.create(
+ problem_descriptor = BlockFactory.create(
category='problem',
data=problem_xml
)
@@ -1781,7 +1781,7 @@ def test_staff_debug_info_score_for_invalid_dropdown(self):
def test_staff_debug_info_disabled_for_detached_blocks(self):
"""Staff markup should not be present on detached blocks."""
- descriptor = ItemFactory.create(
+ descriptor = BlockFactory.create(
category='detached-block',
display_name='Detached Block'
)
@@ -1813,7 +1813,7 @@ def test_histogram_disabled(self):
def test_histogram_enabled_for_unscored_xmodules(self):
"""Histograms should not display for xmodules which are not scored."""
- html_descriptor = ItemFactory.create(
+ html_descriptor = BlockFactory.create(
category='html',
data='Here are some course details.'
)
@@ -2020,7 +2020,7 @@ def handle_callback_and_get_context_info(self,
if problem_display_name:
descriptor_kwargs['display_name'] = problem_display_name
- descriptor = ItemFactory.create(**descriptor_kwargs)
+ descriptor = BlockFactory.create(**descriptor_kwargs)
mock_tracker_for_context = MagicMock()
with patch('lms.djangoapps.courseware.module_render.tracker', mock_tracker_for_context), patch(
'xmodule.services.tracker', mock_tracker_for_context
@@ -2157,8 +2157,8 @@ class TestRebindModule(TestSubmittingProblems):
def setUp(self):
super().setUp()
self.homework = self.add_graded_section_to_course('homework')
- self.lti = ItemFactory.create(category='lti', parent=self.homework)
- self.problem = ItemFactory.create(category='problem', parent=self.homework)
+ self.lti = BlockFactory.create(category='lti', parent=self.homework)
+ self.problem = BlockFactory.create(category='problem', parent=self.homework)
self.user = UserFactory.create()
self.anon_user = AnonymousUser()
@@ -2247,7 +2247,7 @@ def test_event_publishing(self, mock_track_function):
request = self.request_factory.get('')
request.user = self.mock_user
course = CourseFactory()
- descriptor = ItemFactory(category='xblock', parent=course)
+ descriptor = BlockFactory(category='xblock', parent=course)
field_data_cache = FieldDataCache([course, descriptor], course.id, self.mock_user)
block = render.get_module(self.mock_user, request, descriptor.location, field_data_cache)
@@ -2290,7 +2290,7 @@ def setUp(self):
self.student_data = Mock()
self.track_function = Mock()
self.request_token = Mock()
- self.descriptor = ItemFactory(category="pure", parent=self.course)
+ self.descriptor = BlockFactory(category="pure", parent=self.course)
self._prepare_runtime()
@@ -2524,11 +2524,11 @@ def _load_block(self):
"""
Instantiate an XBlock with the appropriate set of children.
"""
- self.parent = ItemFactory(category='xblock', parent=self.course)
+ self.parent = BlockFactory(category='xblock', parent=self.course)
# Create a child for each user
self.children_for_user = {
- user: ItemFactory(category='xblock', parent=self.parent).scope_ids.usage_id # lint-amnesty, pylint: disable=no-member
+ user: BlockFactory(category='xblock', parent=self.parent).scope_ids.usage_id # lint-amnesty, pylint: disable=no-member
for user in self.users.values()
}
@@ -2625,7 +2625,7 @@ def _verify_descriptor(self, category, course, descriptor, item_id=None):
Returns the item's usage_id.
"""
if not item_id:
- item = ItemFactory(category=category, parent=course)
+ item = BlockFactory(category=category, parent=course)
item_id = item.scope_ids.usage_id # lint-amnesty, pylint: disable=no-member
item = self.store.get_item(item_id)
@@ -2653,8 +2653,8 @@ def setUpClass(cls):
number = 'LmsModuleShimTest'
run = '2021_Fall'
cls.course = CourseFactory.create(org=org, number=number, run=run)
- cls.descriptor = ItemFactory(category="vertical", parent=cls.course)
- cls.problem_descriptor = ItemFactory(category="problem", parent=cls.course)
+ cls.descriptor = BlockFactory(category="vertical", parent=cls.course)
+ cls.problem_descriptor = BlockFactory(category="problem", parent=cls.course)
def setUp(self):
"""
@@ -2883,7 +2883,7 @@ def test_replace_jump_to_id_urls(self):
@XBlock.register_temp_plugin(PureXBlock, 'pure')
@XBlock.register_temp_plugin(PureXBlockWithChildren, identifier='xblock')
def test_course_id(self):
- descriptor = ItemFactory(category="pure", parent=self.course)
+ descriptor = BlockFactory(category="pure", parent=self.course)
block = render.get_module(self.user, Mock(), descriptor.location, None)
assert str(block.runtime.course_id) == self.COURSE_ID
diff --git a/lms/djangoapps/courseware/tests/test_navigation.py b/lms/djangoapps/courseware/tests/test_navigation.py
index 1dd954f5e0c9..82b27a5bd6ec 100644
--- a/lms/djangoapps/courseware/tests/test_navigation.py
+++ b/lms/djangoapps/courseware/tests/test_navigation.py
@@ -12,7 +12,7 @@
from edx_toggles.toggles.testutils import override_waffle_flag
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
+from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory
from common.djangoapps.student.tests.factories import GlobalStaffFactory
from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase, set_preview_mode
@@ -34,38 +34,38 @@ def setUpClass(cls):
@classmethod
def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called
- cls.chapter0 = ItemFactory.create(parent=cls.course,
- display_name='Overview')
- cls.chapter9 = ItemFactory.create(parent=cls.course,
- display_name='factory_chapter')
- cls.section0 = ItemFactory.create(parent=cls.chapter0,
- display_name='Welcome')
- cls.section9 = ItemFactory.create(parent=cls.chapter9,
- display_name='factory_section')
- cls.unit0 = ItemFactory.create(parent=cls.section0,
- display_name='New Unit 0')
-
- cls.chapterchrome = ItemFactory.create(parent=cls.course,
- display_name='Chrome')
- cls.chromelesssection = ItemFactory.create(parent=cls.chapterchrome,
- display_name='chromeless',
- chrome='none')
- cls.accordionsection = ItemFactory.create(parent=cls.chapterchrome,
- display_name='accordion',
- chrome='accordion')
- cls.tabssection = ItemFactory.create(parent=cls.chapterchrome,
- display_name='tabs',
- chrome='tabs')
- cls.defaultchromesection = ItemFactory.create(
+ cls.chapter0 = BlockFactory.create(parent=cls.course,
+ display_name='Overview')
+ cls.chapter9 = BlockFactory.create(parent=cls.course,
+ display_name='factory_chapter')
+ cls.section0 = BlockFactory.create(parent=cls.chapter0,
+ display_name='Welcome')
+ cls.section9 = BlockFactory.create(parent=cls.chapter9,
+ display_name='factory_section')
+ cls.unit0 = BlockFactory.create(parent=cls.section0,
+ display_name='New Unit 0')
+
+ cls.chapterchrome = BlockFactory.create(parent=cls.course,
+ display_name='Chrome')
+ cls.chromelesssection = BlockFactory.create(parent=cls.chapterchrome,
+ display_name='chromeless',
+ chrome='none')
+ cls.accordionsection = BlockFactory.create(parent=cls.chapterchrome,
+ display_name='accordion',
+ chrome='accordion')
+ cls.tabssection = BlockFactory.create(parent=cls.chapterchrome,
+ display_name='tabs',
+ chrome='tabs')
+ cls.defaultchromesection = BlockFactory.create(
parent=cls.chapterchrome,
display_name='defaultchrome',
)
- cls.fullchromesection = ItemFactory.create(parent=cls.chapterchrome,
- display_name='fullchrome',
- chrome='accordion,tabs')
- cls.tabtest = ItemFactory.create(parent=cls.chapterchrome,
- display_name='pdf_textbooks_tab',
- default_tab='progress')
+ cls.fullchromesection = BlockFactory.create(parent=cls.chapterchrome,
+ display_name='fullchrome',
+ chrome='accordion,tabs')
+ cls.tabtest = BlockFactory.create(parent=cls.chapterchrome,
+ display_name='pdf_textbooks_tab',
+ default_tab='progress')
cls.user = GlobalStaffFactory(password='test')
@@ -206,7 +206,7 @@ def test_incomplete_course(self):
response = self.assert_request_status_code(200, url)
self.assertContains(response, "No content has been added to this course")
- section = ItemFactory.create(
+ section = BlockFactory.create(
parent_location=self.test_course.location,
display_name='New Section'
)
@@ -218,7 +218,7 @@ def test_incomplete_course(self):
self.assertNotContains(response, "No content has been added to this course")
self.assertContains(response, "New Section")
- subsection = ItemFactory.create(
+ subsection = BlockFactory.create(
parent_location=section.location,
display_name='New Subsection',
)
@@ -230,7 +230,7 @@ def test_incomplete_course(self):
self.assertContains(response, "New Subsection")
self.assertNotContains(response, "sequence-nav")
- ItemFactory.create(
+ BlockFactory.create(
parent_location=subsection.location,
display_name='New Unit',
)
diff --git a/lms/djangoapps/courseware/tests/test_self_paced_overrides.py b/lms/djangoapps/courseware/tests/test_self_paced_overrides.py
index 4eda96ea2c30..fef054a4c966 100644
--- a/lms/djangoapps/courseware/tests/test_self_paced_overrides.py
+++ b/lms/djangoapps/courseware/tests/test_self_paced_overrides.py
@@ -12,7 +12,7 @@
from lms.djangoapps.courseware.field_overrides import OverrideFieldData, OverrideModulestoreFieldData
from openedx.core.djangoapps.discussions.utils import get_accessible_discussion_xblocks
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order
+from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order
@override_settings(
@@ -54,13 +54,13 @@ def setup_course(self, **course_kwargs):
overrides are correctly applied for both blocks.
"""
course = CourseFactory.create(**course_kwargs)
- section = ItemFactory.create(parent=course, due=self.now)
+ section = BlockFactory.create(parent=course, due=self.now)
inject_field_overrides((course, section), course, self.user)
return (course, section)
def create_discussion_xblocks(self, parent): # lint-amnesty, pylint: disable=missing-function-docstring
# Create a released discussion xblock
- ItemFactory.create(
+ BlockFactory.create(
parent=parent,
category='discussion',
display_name='released',
@@ -68,7 +68,7 @@ def create_discussion_xblocks(self, parent): # lint-amnesty, pylint: disable=mi
)
# Create a scheduled discussion xblock
- ItemFactory.create(
+ BlockFactory.create(
parent=parent,
category='discussion',
display_name='scheduled',
diff --git a/lms/djangoapps/courseware/tests/test_services.py b/lms/djangoapps/courseware/tests/test_services.py
index 1e68317d06b5..b3e862142b41 100644
--- a/lms/djangoapps/courseware/tests/test_services.py
+++ b/lms/djangoapps/courseware/tests/test_services.py
@@ -12,7 +12,7 @@
from lms.djangoapps.courseware.services import UserStateService
from lms.djangoapps.courseware.tests.factories import StudentModuleFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order
+from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order
@ddt.ddt
@@ -28,22 +28,22 @@ def setUp(self):
super().setUp()
self.user = UserFactory.create()
self.course = CourseFactory.create()
- chapter = ItemFactory.create(
+ chapter = BlockFactory.create(
category='chapter',
parent=self.course,
display_name='Test Chapter'
)
- sequential = ItemFactory.create(
+ sequential = BlockFactory.create(
category='sequential',
parent=chapter,
display_name='Test Sequential'
)
- vertical = ItemFactory.create(
+ vertical = BlockFactory.create(
category='vertical',
parent=sequential,
display_name='Test Vertical'
)
- self.problem = ItemFactory.create(
+ self.problem = BlockFactory.create(
category='problem',
parent=vertical,
display_name='Test Problem'
diff --git a/lms/djangoapps/courseware/tests/test_split_module.py b/lms/djangoapps/courseware/tests/test_split_module.py
index f756734b1092..fb33874d730b 100644
--- a/lms/djangoapps/courseware/tests/test_split_module.py
+++ b/lms/djangoapps/courseware/tests/test_split_module.py
@@ -6,7 +6,7 @@
from unittest.mock import MagicMock
from django.urls import reverse
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
+from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory
from xmodule.partitions.partitions import Group, UserPartition
from lms.djangoapps.courseware.model_data import FieldDataCache
@@ -46,12 +46,12 @@ def setUp(self):
number=self.COURSE_NUMBER,
user_partitions=[self.partition]
)
- self.chapter = ItemFactory.create(
+ self.chapter = BlockFactory.create(
parent_location=self.course.location,
category="chapter",
display_name="test chapter",
)
- self.sequential = ItemFactory.create(
+ self.sequential = BlockFactory.create(
parent_location=self.chapter.location,
category="sequential",
display_name="Split Test Tests",
@@ -69,7 +69,7 @@ def _video(self, parent, group):
Returns a video component with parent ``parent``
that is intended to be displayed to group ``group``.
"""
- return ItemFactory.create(
+ return BlockFactory.create(
parent_location=parent.location,
category="video",
display_name=f"Group {group} Sees This Video",
@@ -80,7 +80,7 @@ def _problem(self, parent, group):
Returns a problem component with parent ``parent``
that is intended to be displayed to group ``group``.
"""
- return ItemFactory.create(
+ return BlockFactory.create(
parent_location=parent.location,
category="problem",
display_name=f"Group {group} Sees This Problem",
@@ -92,7 +92,7 @@ def _html(self, parent, group):
Returns an html component with parent ``parent``
that is intended to be displayed to group ``group``.
"""
- return ItemFactory.create(
+ return BlockFactory.create(
parent_location=parent.location,
category="html",
display_name=f"Group {group} Sees This HTML",
@@ -166,7 +166,7 @@ def setUp(self):
c0_url = self.course.id.make_usage_key("vertical", "split_test_cond0")
c1_url = self.course.id.make_usage_key("vertical", "split_test_cond1")
- split_test = ItemFactory.create(
+ split_test = BlockFactory.create(
parent_location=self.sequential.location,
category="split_test",
display_name="Split test",
@@ -174,7 +174,7 @@ def setUp(self):
group_id_to_child={"0": c0_url, "1": c1_url},
)
- cond0vert = ItemFactory.create(
+ cond0vert = BlockFactory.create(
parent_location=split_test.location,
category="vertical",
display_name="Condition 0 vertical",
@@ -183,7 +183,7 @@ def setUp(self):
video0 = self._video(cond0vert, 0)
problem0 = self._problem(cond0vert, 0)
- cond1vert = ItemFactory.create(
+ cond1vert = BlockFactory.create(
parent_location=split_test.location,
category="vertical",
display_name="Condition 1 vertical",
@@ -231,7 +231,7 @@ def setUp(self):
# We define problem compenents that we need but don't explicitly call elsewhere.
super().setUp()
- vert1 = ItemFactory.create(
+ vert1 = BlockFactory.create(
parent_location=self.sequential.location,
category="vertical",
display_name="Split test vertical",
@@ -239,7 +239,7 @@ def setUp(self):
c0_url = self.course.id.make_usage_key("vertical", "split_test_cond0")
c1_url = self.course.id.make_usage_key("vertical", "split_test_cond1")
- split_test = ItemFactory.create(
+ split_test = BlockFactory.create(
parent_location=vert1.location,
category="split_test",
display_name="Split test",
@@ -247,7 +247,7 @@ def setUp(self):
group_id_to_child={"0": c0_url, "1": c1_url},
)
- cond0vert = ItemFactory.create(
+ cond0vert = BlockFactory.create(
parent_location=split_test.location,
category="vertical",
display_name="Condition 0 Vertical",
@@ -256,7 +256,7 @@ def setUp(self):
video0 = self._video(cond0vert, 0)
problem0 = self._problem(cond0vert, 0)
- cond1vert = ItemFactory.create(
+ cond1vert = BlockFactory.create(
parent_location=split_test.location,
category="vertical",
display_name="Condition 1 Vertical",
@@ -298,7 +298,7 @@ def setUpClass(cls):
user_partitions=[cls.partition]
)
- cls.chapter = ItemFactory.create(
+ cls.chapter = BlockFactory.create(
parent_location=cls.course.location,
category="chapter",
display_name="test chapter",
diff --git a/lms/djangoapps/courseware/tests/test_submitting_problems.py b/lms/djangoapps/courseware/tests/test_submitting_problems.py
index 8be60877c3d0..8ffcea0298bf 100644
--- a/lms/djangoapps/courseware/tests/test_submitting_problems.py
+++ b/lms/djangoapps/courseware/tests/test_submitting_problems.py
@@ -39,7 +39,7 @@
from openedx.core.lib.url_utils import quote_slashes
from common.djangoapps.student.models import CourseEnrollment, anonymous_id_for_user
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # 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 Group, UserPartition # lint-amnesty, pylint: disable=wrong-import-order
@@ -181,7 +181,7 @@ def add_dropdown_to_section(self, section_location, name, num_inputs=2):
correct_option='Correct'
)
- problem = ItemFactory.create(
+ problem = BlockFactory.create(
parent_location=section_location,
category='problem',
data=prob_xml,
@@ -200,13 +200,13 @@ def add_graded_section_to_course(self, name, section_format='Homework', late=Fal
# if we don't already have a chapter create a new one
if not hasattr(self, 'chapter'):
- self.chapter = ItemFactory.create(
+ self.chapter = BlockFactory.create(
parent_location=self.course.location,
category='chapter'
)
if late:
- section = ItemFactory.create(
+ section = BlockFactory.create(
parent_location=self.chapter.location,
display_name=name,
category='sequential',
@@ -217,7 +217,7 @@ def add_graded_section_to_course(self, name, section_format='Homework', late=Fal
},
)
elif reset:
- section = ItemFactory.create(
+ section = BlockFactory.create(
parent_location=self.chapter.location,
display_name=name,
category='sequential',
@@ -229,7 +229,7 @@ def add_graded_section_to_course(self, name, section_format='Homework', late=Fal
)
elif showanswer:
- section = ItemFactory.create(
+ section = BlockFactory.create(
parent_location=self.chapter.location,
display_name=name,
category='sequential',
@@ -241,7 +241,7 @@ def add_graded_section_to_course(self, name, section_format='Homework', late=Fal
)
else:
- section = ItemFactory.create(
+ section = BlockFactory.create(
parent_location=self.chapter.location,
display_name=name,
category='sequential',
@@ -773,7 +773,7 @@ def problem_setup(self, name, files):
xmldata = CodeResponseXMLFactory().build_xml(
allowed_files=files, required_files=files,
)
- ItemFactory.create(
+ BlockFactory.create(
parent_location=self.section.location,
category='problem',
display_name=name,
@@ -919,7 +919,7 @@ def schematic_setup(self, name):
script = self.SCHEMATIC_SCRIPT
xmldata = SchematicResponseXMLFactory().build_xml(answer=script)
- ItemFactory.create(
+ BlockFactory.create(
parent_location=self.section.location,
category='problem',
boilerplate='circuitschematic.yaml',
@@ -943,7 +943,7 @@ def custom_response_setup(self, name):
expect = self.CUSTOM_RESPONSE_CORRECT
cfn_problem_xml = CustomResponseXMLFactory().build_xml(script=test_csv, cfn='test_csv', expect=expect)
- ItemFactory.create(
+ BlockFactory.create(
parent_location=self.section.location,
category='problem',
boilerplate='customgrader.yaml',
@@ -967,7 +967,7 @@ def computed_answer_setup(self, name):
computed_xml = CustomResponseXMLFactory().build_xml(answer=script)
- ItemFactory.create(
+ BlockFactory.create(
parent_location=self.section.location,
category='problem',
boilerplate='customgrader.yaml',
@@ -1120,7 +1120,7 @@ def split_setup(self, user_partition_group):
for index, url in enumerate([vertical_0_url, vertical_1_url]):
group_id_to_child[str(index)] = url
- split_test = ItemFactory.create(
+ split_test = BlockFactory.create(
parent_location=self.homework_conditional.location,
category="split_test",
display_name="Split test",
@@ -1128,14 +1128,14 @@ def split_setup(self, user_partition_group):
group_id_to_child=group_id_to_child,
)
- vertical_0 = ItemFactory.create(
+ vertical_0 = BlockFactory.create(
parent_location=split_test.location,
category="vertical",
display_name="Condition 0 vertical",
location=vertical_0_url,
)
- vertical_1 = ItemFactory.create(
+ vertical_1 = BlockFactory.create(
parent_location=split_test.location,
category="vertical",
display_name="Condition 1 vertical",
diff --git a/lms/djangoapps/courseware/tests/test_tabs.py b/lms/djangoapps/courseware/tests/test_tabs.py
index c2f65e069a8e..f65729961057 100644
--- a/lms/djangoapps/courseware/tests/test_tabs.py
+++ b/lms/djangoapps/courseware/tests/test_tabs.py
@@ -42,7 +42,7 @@
ModuleStoreTestCase,
SharedModuleStoreTestCase
)
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order
+from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.utils import TEST_DATA_DIR # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.xml_importer import import_course_from_xml # lint-amnesty, pylint: disable=wrong-import-order
@@ -242,7 +242,7 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
def setUpClass(cls):
super().setUpClass()
cls.course = CourseFactory.create()
- cls.page = ItemFactory.create(
+ cls.page = BlockFactory.create(
category="static_tab", parent_location=cls.course.location,
data="OOGIE BLOOGIE", display_name="new_tab"
)
@@ -346,11 +346,11 @@ def setUp(self):
super().setUp()
self.course = CourseFactory.create()
- self.extra_tab_2 = ItemFactory.create(
+ self.extra_tab_2 = BlockFactory.create(
category="static_tab", parent_location=self.course.location,
data="Extra Tab", display_name="Extra Tab 2"
)
- self.extra_tab_3 = ItemFactory.create(
+ self.extra_tab_3 = BlockFactory.create(
category="static_tab", parent_location=self.course.location,
data="Extra Tab", display_name="Extra Tab 3"
)
@@ -364,7 +364,7 @@ def test_get_course_tabs_list_entrance_exam_enabled(self):
"""
Unit Test: test_get_course_tabs_list_entrance_exam_enabled
"""
- entrance_exam = ItemFactory.create(
+ entrance_exam = BlockFactory.create(
category="chapter",
parent_location=self.course.location,
display_name="Entrance Exam",
diff --git a/lms/djangoapps/courseware/tests/test_video_xml.py b/lms/djangoapps/courseware/tests/test_video_xml.py
index 4e84168bda28..67787f91216d 100644
--- a/lms/djangoapps/courseware/tests/test_video_xml.py
+++ b/lms/djangoapps/courseware/tests/test_video_xml.py
@@ -9,7 +9,7 @@
You use this so that it will do things like point the modulestore
setting to mongo, flush the contentstore before and after, load the
templates, etc.
-You can then use the CourseFactory and XModuleItemFactory as defined in
+You can then use the CourseFactory and BlockFactory as defined in
xmodule/modulestore/tests/factories.py to create the
course, section, subsection, unit, etc.
"""
diff --git a/lms/djangoapps/courseware/tests/test_view_authentication.py b/lms/djangoapps/courseware/tests/test_view_authentication.py
index c758b051a511..42f2275e0fd2 100644
--- a/lms/djangoapps/courseware/tests/test_view_authentication.py
+++ b/lms/djangoapps/courseware/tests/test_view_authentication.py
@@ -10,7 +10,7 @@
from django.urls import reverse
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
+from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory
from common.djangoapps.student.tests.factories import BetaTesterFactory
from common.djangoapps.student.tests.factories import GlobalStaffFactory
@@ -117,16 +117,16 @@ def setUp(self):
super().setUp()
self.course = CourseFactory.create(number='999', display_name='Robot_Super_Course')
- self.courseware_chapter = ItemFactory.create(display_name='courseware')
- self.overview_chapter = ItemFactory.create(
+ self.courseware_chapter = BlockFactory.create(display_name='courseware')
+ self.overview_chapter = BlockFactory.create(
parent_location=self.course.location,
display_name='Super Overview'
)
- self.welcome_section = ItemFactory.create(
+ self.welcome_section = BlockFactory.create(
parent_location=self.overview_chapter.location,
display_name='Super Welcome'
)
- self.welcome_unit = ItemFactory.create(
+ self.welcome_unit = BlockFactory.create(
parent_location=self.welcome_section.location,
display_name='Super Unit'
)
@@ -134,19 +134,19 @@ def setUp(self):
self.test_course = CourseFactory.create(org=self.course.id.org)
self.other_org_course = CourseFactory.create(org='Other_Org_Course')
- self.sub_courseware_chapter = ItemFactory.create(
+ self.sub_courseware_chapter = BlockFactory.create(
parent_location=self.test_course.location,
display_name='courseware'
)
- self.sub_overview_chapter = ItemFactory.create(
+ self.sub_overview_chapter = BlockFactory.create(
parent_location=self.sub_courseware_chapter.location,
display_name='Overview'
)
- self.sub_welcome_section = ItemFactory.create(
+ self.sub_welcome_section = BlockFactory.create(
parent_location=self.sub_overview_chapter.location,
display_name='Welcome'
)
- self.sub_welcome_unit = ItemFactory.create(
+ self.sub_welcome_unit = BlockFactory.create(
parent_location=self.sub_welcome_section.location,
display_name='New Unit'
)
@@ -423,7 +423,7 @@ def setUp(self):
tomorrow = now + datetime.timedelta(days=1)
self.course = CourseFactory(days_early_for_beta=2, start=tomorrow)
- self.content = ItemFactory(parent=self.course)
+ self.content = BlockFactory(parent=self.course)
self.normal_student = UserFactory()
self.beta_tester = BetaTesterFactory(course_key=self.course.id) # lint-amnesty, pylint: disable=no-member
diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py
index 063fe5299e7e..f7e1b9f6c120 100644
--- a/lms/djangoapps/courseware/tests/test_views.py
+++ b/lms/djangoapps/courseware/tests/test_views.py
@@ -37,7 +37,7 @@
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.django_utils import CourseUserType, ModuleStoreTestCase, SharedModuleStoreTestCase
-from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
+from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls
import lms.djangoapps.courseware.views.views as views
from common.djangoapps.course_modes.models import CourseMode
@@ -123,7 +123,7 @@ def test_jump_to_legacy_vs_mfe(self, preview_mode, expect_mfe):
Can be removed when the MFE supports a preview mode.
"""
course = CourseFactory.create()
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
if expect_mfe:
expected_url = f'http://learning-mfe/course/{course.id}/{chapter.location}'
else:
@@ -170,8 +170,8 @@ def test_jump_to_invalid_location(self, preview_mode, store_type):
def test_jump_to_legacy_from_sequence(self):
with self.store.default_store(ModuleStoreEnum.Type.split):
course = CourseFactory.create()
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- sequence = ItemFactory.create(category='sequential', parent_location=chapter.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ sequence = BlockFactory.create(category='sequential', parent_location=chapter.location)
activate_block_id = urlencode({'activate_block_id': str(sequence.location)})
expected_redirect_url = (
f'/courses/{course.id}/courseware/{chapter.url_name}/{sequence.url_name}/?{activate_block_id}'
@@ -183,8 +183,8 @@ def test_jump_to_legacy_from_sequence(self):
@set_preview_mode(False)
def test_jump_to_mfe_from_sequence(self):
course = CourseFactory.create()
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- sequence = ItemFactory.create(category='sequential', parent_location=chapter.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ sequence = BlockFactory.create(category='sequential', parent_location=chapter.location)
expected_redirect_url = (
f'http://learning-mfe/course/{course.id}/{sequence.location}'
)
@@ -197,12 +197,12 @@ def test_jump_to_mfe_from_sequence(self):
def test_jump_to_legacy_from_module(self):
with self.store.default_store(ModuleStoreEnum.Type.split):
course = CourseFactory.create()
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- sequence = ItemFactory.create(category='sequential', parent_location=chapter.location)
- vertical1 = ItemFactory.create(category='vertical', parent_location=sequence.location)
- vertical2 = ItemFactory.create(category='vertical', parent_location=sequence.location)
- module1 = ItemFactory.create(category='html', parent_location=vertical1.location)
- module2 = ItemFactory.create(category='html', parent_location=vertical2.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ sequence = BlockFactory.create(category='sequential', parent_location=chapter.location)
+ vertical1 = BlockFactory.create(category='vertical', parent_location=sequence.location)
+ vertical2 = BlockFactory.create(category='vertical', parent_location=sequence.location)
+ module1 = BlockFactory.create(category='html', parent_location=vertical1.location)
+ module2 = BlockFactory.create(category='html', parent_location=vertical2.location)
activate_block_id = urlencode({'activate_block_id': str(module1.location)})
expected_redirect_url = (
@@ -223,12 +223,12 @@ def test_jump_to_legacy_from_module(self):
@set_preview_mode(False)
def test_jump_to_mfe_from_module(self):
course = CourseFactory.create()
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- sequence = ItemFactory.create(category='sequential', parent_location=chapter.location)
- vertical1 = ItemFactory.create(category='vertical', parent_location=sequence.location)
- vertical2 = ItemFactory.create(category='vertical', parent_location=sequence.location)
- module1 = ItemFactory.create(category='html', parent_location=vertical1.location)
- module2 = ItemFactory.create(category='html', parent_location=vertical2.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ sequence = BlockFactory.create(category='sequential', parent_location=chapter.location)
+ vertical1 = BlockFactory.create(category='vertical', parent_location=sequence.location)
+ vertical2 = BlockFactory.create(category='vertical', parent_location=sequence.location)
+ module1 = BlockFactory.create(category='html', parent_location=vertical1.location)
+ module2 = BlockFactory.create(category='html', parent_location=vertical2.location)
expected_redirect_url = (
f'http://learning-mfe/course/{course.id}/{sequence.location}/{vertical1.location}'
@@ -252,15 +252,15 @@ def test_jump_to_mfe_from_module(self):
def test_jump_to_legacy_from_nested_module(self):
with self.store.default_store(ModuleStoreEnum.Type.split):
course = CourseFactory.create()
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- sequence = ItemFactory.create(category='sequential', parent_location=chapter.location)
- vertical = ItemFactory.create(category='vertical', parent_location=sequence.location)
- nested_sequence = ItemFactory.create(category='sequential', parent_location=vertical.location)
- nested_vertical1 = ItemFactory.create(category='vertical', parent_location=nested_sequence.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ sequence = BlockFactory.create(category='sequential', parent_location=chapter.location)
+ vertical = BlockFactory.create(category='vertical', parent_location=sequence.location)
+ nested_sequence = BlockFactory.create(category='sequential', parent_location=vertical.location)
+ nested_vertical1 = BlockFactory.create(category='vertical', parent_location=nested_sequence.location)
# put a module into nested_vertical1 for completeness
- ItemFactory.create(category='html', parent_location=nested_vertical1.location)
- nested_vertical2 = ItemFactory.create(category='vertical', parent_location=nested_sequence.location)
- module2 = ItemFactory.create(category='html', parent_location=nested_vertical2.location)
+ BlockFactory.create(category='html', parent_location=nested_vertical1.location)
+ nested_vertical2 = BlockFactory.create(category='vertical', parent_location=nested_sequence.location)
+ module2 = BlockFactory.create(category='html', parent_location=nested_vertical2.location)
# internal position of module2 will be 1_2 (2nd item withing 1st item)
activate_block_id = urlencode({'activate_block_id': str(module2.location)})
@@ -303,12 +303,12 @@ def test_jump_to_legacy_for_learner_with_staff_only_content(self, store_type, is
request.user = UserFactory(is_staff=is_staff_user, username="staff")
request.session = {}
course_key = CourseKey.from_string(str(course.id))
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- sequence = ItemFactory.create(category='sequential', parent_location=chapter.location)
- __ = ItemFactory.create(category='vertical', parent_location=sequence.location)
- staff_only_vertical = ItemFactory.create(category='vertical', parent_location=sequence.location,
- metadata=dict(visible_to_staff_only=True))
- __ = ItemFactory.create(category='vertical', parent_location=sequence.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ sequence = BlockFactory.create(category='sequential', parent_location=chapter.location)
+ __ = BlockFactory.create(category='vertical', parent_location=sequence.location)
+ staff_only_vertical = BlockFactory.create(category='vertical', parent_location=sequence.location,
+ metadata=dict(visible_to_staff_only=True))
+ __ = BlockFactory.create(category='vertical', parent_location=sequence.location)
usage_key = UsageKey.from_string(str(staff_only_vertical.location)).replace(course_key=course_key)
expected_url = reverse(
@@ -337,11 +337,11 @@ def test_index_query_counts(self):
with self.store.default_store(ModuleStoreEnum.Type.split):
course = CourseFactory.create()
with self.store.bulk_operations(course.id):
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- section = ItemFactory.create(category='sequential', parent_location=chapter.location)
- vertical = ItemFactory.create(category='vertical', parent_location=section.location)
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ section = BlockFactory.create(category='sequential', parent_location=chapter.location)
+ vertical = BlockFactory.create(category='vertical', parent_location=section.location)
for _ in range(self.NUM_PROBLEMS):
- ItemFactory.create(category='problem', parent_location=vertical.location)
+ BlockFactory.create(category='problem', parent_location=vertical.location)
self.client.login(username=self.user.username, password=self.user_password)
CourseEnrollment.enroll(self.user, course.id)
@@ -368,40 +368,40 @@ def setUp(self):
super().setUp()
self.course = CourseFactory.create(display_name='teꜱᴛ course', run="Testing_course")
with self.store.bulk_operations(self.course.id):
- self.chapter = ItemFactory.create(
+ self.chapter = BlockFactory.create(
category='chapter',
parent_location=self.course.location,
display_name="Chapter 1",
)
- self.section = ItemFactory.create(
+ self.section = BlockFactory.create(
category='sequential',
parent_location=self.chapter.location,
due=datetime(2013, 9, 18, 11, 30, 00),
display_name='Sequential 1',
format='Homework'
)
- self.vertical = ItemFactory.create(
+ self.vertical = BlockFactory.create(
category='vertical',
parent_location=self.section.location,
display_name='Vertical 1',
)
- self.problem = ItemFactory.create(
+ self.problem = BlockFactory.create(
category='problem',
parent_location=self.vertical.location,
display_name='Problem 1',
)
- self.section2 = ItemFactory.create(
+ self.section2 = BlockFactory.create(
category='sequential',
parent_location=self.chapter.location,
display_name='Sequential 2',
)
- self.vertical2 = ItemFactory.create(
+ self.vertical2 = BlockFactory.create(
category='vertical',
parent_location=self.section2.location,
display_name='Vertical 2',
)
- self.problem2 = ItemFactory.create(
+ self.problem2 = BlockFactory.create(
category='problem',
parent_location=self.vertical2.location,
display_name='Problem 2',
@@ -1084,15 +1084,15 @@ def set_up_course(self, **course_kwargs):
"""
course = CourseFactory.create(**course_kwargs)
with self.store.bulk_operations(course.id):
- chapter = ItemFactory.create(category='chapter', parent_location=course.location)
- section = ItemFactory.create(
+ chapter = BlockFactory.create(category='chapter', parent_location=course.location)
+ section = BlockFactory.create(
category='sequential',
parent_location=chapter.location,
due=datetime(2013, 9, 18, 11, 30, 00),
format='homework'
)
- vertical = ItemFactory.create(category='vertical', parent_location=section.location)
- ItemFactory.create(category='problem', parent_location=vertical.location)
+ vertical = BlockFactory.create(category='vertical', parent_location=section.location)
+ BlockFactory.create(category='problem', parent_location=vertical.location)
course = modulestore().get_course(course.id)
assert course.get_children()[0].get_children()[0].due is not None
@@ -1263,9 +1263,9 @@ def setup_course(self, **course_options):
"""Create the test course and content, and enroll the user."""
self.create_course(**course_options, grading_policy={'GRADE_CUTOFFS': {'çü†øƒƒ': 0.75, 'Pass': 0.5}})
with self.store.bulk_operations(self.course.id):
- self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location)
- self.section = ItemFactory.create(category='sequential', parent_location=self.chapter.location)
- self.vertical = ItemFactory.create(category='vertical', parent_location=self.section.location)
+ self.chapter = BlockFactory.create(category='chapter', parent_location=self.course.location)
+ self.section = BlockFactory.create(category='sequential', parent_location=self.chapter.location)
+ self.vertical = BlockFactory.create(category='vertical', parent_location=self.section.location)
CourseEnrollmentFactory(user=self.user, course_id=self.course.id, mode=CourseMode.HONOR)
@@ -1307,7 +1307,7 @@ def test_progress_page_xss_prevent(self, malicious_code):
self.assertNotContains(resp, malicious_code)
def test_pure_ungraded_xblock(self):
- ItemFactory.create(category='acid', parent_location=self.vertical.location)
+ BlockFactory.create(category='acid', parent_location=self.vertical.location)
self._get_progress_page()
def test_student_progress_with_valid_and_invalid_id(self):
@@ -1901,11 +1901,11 @@ def setup_course(self, show_correctness='', due_date=None, graded=False, **cours
metadata['format'] = self.GRADER_TYPE
with self.store.bulk_operations(self.course.id):
- self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location,
- display_name="Section 1")
- self.section = ItemFactory.create(category='sequential', parent_location=self.chapter.location,
- display_name="Subsection 1", metadata=metadata)
- self.vertical = ItemFactory.create(category='vertical', parent_location=self.section.location)
+ self.chapter = BlockFactory.create(category='chapter', parent_location=self.course.location,
+ display_name="Section 1")
+ self.section = BlockFactory.create(category='sequential', parent_location=self.chapter.location,
+ display_name="Subsection 1", metadata=metadata)
+ self.vertical = BlockFactory.create(category='vertical', parent_location=self.section.location)
CourseEnrollmentFactory(user=self.user, course_id=self.course.id, mode=CourseMode.HONOR)
@@ -1918,8 +1918,8 @@ def add_problem(self):
choices=[True, False],
choice_names=['choice_0', 'choice_1']
)
- self.problem = ItemFactory.create(category='problem', parent_location=self.vertical.location, # lint-amnesty, pylint: disable=attribute-defined-outside-init
- data=problem_xml, display_name='Problem 1')
+ self.problem = BlockFactory.create(category='problem', parent_location=self.vertical.location, # lint-amnesty, pylint: disable=attribute-defined-outside-init
+ data=problem_xml, display_name='Problem 1')
# Re-fetch the course from the database
self.course = self.store.get_course(self.course.id) # lint-amnesty, pylint: disable=attribute-defined-outside-init
@@ -2382,13 +2382,13 @@ def test_student_state(self):
"""
with modulestore().default_store(ModuleStoreEnum.Type.split):
course = CourseFactory.create()
- chapter = ItemFactory.create(parent_location=course.location, category='chapter')
- section = ItemFactory.create(parent_location=chapter.location, category='view_checker',
- display_name="Sequence Checker")
- vertical = ItemFactory.create(parent_location=section.location, category='view_checker',
- display_name="Vertical Checker")
- block = ItemFactory.create(parent_location=vertical.location, category='view_checker',
- display_name="Block Checker")
+ chapter = BlockFactory.create(parent_location=course.location, category='chapter')
+ section = BlockFactory.create(parent_location=chapter.location, category='view_checker',
+ display_name="Sequence Checker")
+ vertical = BlockFactory.create(parent_location=section.location, category='view_checker',
+ display_name="Vertical Checker")
+ block = BlockFactory.create(parent_location=vertical.location, category='view_checker',
+ display_name="Block Checker")
for item in (section, vertical, block):
StudentModuleFactory.create(
@@ -2419,10 +2419,10 @@ def test_student_state(self):
def test_activate_block_id(self):
course = CourseFactory.create()
with self.store.bulk_operations(course.id):
- chapter = ItemFactory.create(parent=course, category='chapter')
- section = ItemFactory.create(parent=chapter, category='sequential', display_name="Sequence")
- vertical = ItemFactory.create(parent=section, category='vertical', display_name="Vertical")
- ItemFactory.create(parent=vertical, category='id_checker', display_name="ID Checker")
+ chapter = BlockFactory.create(parent=course, category='chapter')
+ section = BlockFactory.create(parent=chapter, category='sequential', display_name="Sequence")
+ vertical = BlockFactory.create(parent=section, category='vertical', display_name="Vertical")
+ BlockFactory.create(parent=vertical, category='id_checker', display_name="ID Checker")
CourseOverview.load_from_module_store(course.id)
CourseEnrollmentFactory(user=self.user, course_id=course.id)
@@ -2543,35 +2543,35 @@ def setup_course(self, default_store):
with self.store.bulk_operations(self.course.id):
- self.chapter = ItemFactory.create(
+ self.chapter = BlockFactory.create(
parent_location=self.course.location, category='chapter', display_name='Week 1'
)
- self.section_1 = ItemFactory.create(
+ self.section_1 = BlockFactory.create(
parent_location=self.chapter.location, category='sequential', display_name='Lesson 1'
)
- self.vertical_1 = ItemFactory.create(
+ self.vertical_1 = BlockFactory.create(
parent_location=self.section_1.location, category='vertical', display_name='Subsection 1'
)
- self.html_1_1 = ItemFactory.create(
+ self.html_1_1 = BlockFactory.create(
parent_location=self.vertical_1.location, category='html', display_name="HTML 1_1"
)
- self.problem_1 = ItemFactory.create(
+ self.problem_1 = BlockFactory.create(
parent_location=self.vertical_1.location, category='problem', display_name="Problem 1"
)
- self.html_1_2 = ItemFactory.create(
+ self.html_1_2 = BlockFactory.create(
parent_location=self.vertical_1.location, category='html', display_name="HTML 1_2"
)
- self.section_2 = ItemFactory.create(
+ self.section_2 = BlockFactory.create(
parent_location=self.chapter.location, category='sequential', display_name='Lesson 2'
)
- self.vertical_2 = ItemFactory.create(
+ self.vertical_2 = BlockFactory.create(
parent_location=self.section_2.location, category='vertical', display_name='Subsection 2'
)
- self.video_2 = ItemFactory.create(
+ self.video_2 = BlockFactory.create(
parent_location=self.vertical_2.location, category='video', display_name="Video 2"
)
- self.problem_2 = ItemFactory.create(
+ self.problem_2 = BlockFactory.create(
parent_location=self.vertical_2.location, category='problem', display_name="Problem 2"
)
@@ -2675,12 +2675,12 @@ def setUp(self):
# create course with 3 positions
self.course = CourseFactory.create()
with self.store.bulk_operations(self.course.id):
- self.chapter = ItemFactory.create(parent_location=self.course.location, category='chapter')
- self.section = ItemFactory.create(parent_location=self.chapter.location, category='sequential',
- display_name="Sequence")
- ItemFactory.create(parent_location=self.section.location, category='vertical', display_name="Vertical1")
- ItemFactory.create(parent_location=self.section.location, category='vertical', display_name="Vertical2")
- ItemFactory.create(parent_location=self.section.location, category='vertical', display_name="Vertical3")
+ self.chapter = BlockFactory.create(parent_location=self.course.location, category='chapter')
+ self.section = BlockFactory.create(parent_location=self.chapter.location, category='sequential',
+ display_name="Sequence")
+ BlockFactory.create(parent_location=self.section.location, category='vertical', display_name="Vertical1")
+ BlockFactory.create(parent_location=self.section.location, category='vertical', display_name="Vertical2")
+ BlockFactory.create(parent_location=self.section.location, category='vertical', display_name="Vertical3")
CourseOverview.load_from_module_store(self.course.id)
@@ -2808,24 +2808,24 @@ def test_rendering_descendant_of_gated_sequence(self):
with self.store.default_store(ModuleStoreEnum.Type.split):
# pylint:disable=attribute-defined-outside-init
self.course = CourseFactory.create(**self.course_options())
- self.chapter = ItemFactory.create(parent=self.course, category='chapter')
- self.sequence = ItemFactory.create(
+ self.chapter = BlockFactory.create(parent=self.course, category='chapter')
+ self.sequence = BlockFactory.create(
parent=self.chapter,
category='sequential',
display_name='Sequence',
is_time_limited=True,
)
- self.vertical_block = ItemFactory.create(
+ self.vertical_block = BlockFactory.create(
parent=self.sequence,
category='vertical',
display_name="Vertical",
)
- self.html_block = ItemFactory.create(
+ self.html_block = BlockFactory.create(
parent=self.vertical_block,
category='html',
data="Test HTML Content
" ) - self.problem_block = ItemFactory.create( + self.problem_block = BlockFactory.create( parent=self.vertical_block, category='problem', display_name='Problem' @@ -2851,24 +2851,24 @@ def test_rendering_descendant_of_gated_sequence_with_masquerade(self): with self.store.default_store(ModuleStoreEnum.Type.split): # pylint:disable=attribute-defined-outside-init self.course = CourseFactory.create(**self.course_options()) - self.chapter = ItemFactory.create(parent=self.course, category='chapter') - self.sequence = ItemFactory.create( + self.chapter = BlockFactory.create(parent=self.course, category='chapter') + self.sequence = BlockFactory.create( parent=self.chapter, category='sequential', display_name='Sequence', is_time_limited=True, ) - self.vertical_block = ItemFactory.create( + self.vertical_block = BlockFactory.create( parent=self.sequence, category='vertical', display_name="Vertical", ) - self.html_block = ItemFactory.create( + self.html_block = BlockFactory.create( parent=self.vertical_block, category='html', data="
Test HTML Content
" ) - self.problem_block = ItemFactory.create( + self.problem_block = BlockFactory.create( parent=self.vertical_block, category='problem', display_name='Problem' @@ -2936,24 +2936,24 @@ def setup_course(self): """ with self.store.default_store(self.store.default_modulestore.get_modulestore_type()): course = CourseFactory.create(**{'start': datetime.now() - timedelta(days=1)}) - chapter = ItemFactory.create(parent=course, category='chapter') - vertical_block = ItemFactory.create( + chapter = BlockFactory.create(parent=course, category='chapter') + vertical_block = BlockFactory.create( parent_location=chapter.location, category='vertical', display_name="Vertical" ) - self.html_block = ItemFactory.create( # pylint: disable=attribute-defined-outside-init + self.html_block = BlockFactory.create( # pylint: disable=attribute-defined-outside-init parent=vertical_block, category='html', data="
Test HTML Content
" ) - self.video_block_public = ItemFactory.create( # pylint: disable=attribute-defined-outside-init + self.video_block_public = BlockFactory.create( # pylint: disable=attribute-defined-outside-init parent=vertical_block, category='video', display_name='Video with public access', metadata={'public_access': True} ) - self.video_block_not_public = ItemFactory.create( # pylint: disable=attribute-defined-outside-init + self.video_block_not_public = BlockFactory.create( # pylint: disable=attribute-defined-outside-init parent=vertical_block, category='video', display_name='Video with private access' @@ -3029,9 +3029,9 @@ def setUpClass(cls): with super().setUpClassAndTestData(): cls.course = CourseFactory.create() with cls.store.bulk_operations(cls.course.id): - cls.chapter = ItemFactory.create(category='chapter', parent_location=cls.course.location) - cls.section = ItemFactory.create(category='sequential', parent_location=cls.chapter.location) - cls.vertical = ItemFactory.create(category='vertical', parent_location=cls.section.location) + cls.chapter = BlockFactory.create(category='chapter', parent_location=cls.course.location) + cls.section = BlockFactory.create(category='sequential', parent_location=cls.chapter.location) + cls.vertical = BlockFactory.create(category='vertical', parent_location=cls.section.location) @classmethod def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called @@ -3214,24 +3214,24 @@ def setUp(self): with self.store.default_store(ModuleStoreEnum.Type.split): self.course = CourseFactory.create(display_name='teꜱᴛ course', run="Testing_course") with self.store.bulk_operations(self.course.id): - chapter = ItemFactory.create( + chapter = BlockFactory.create( category='chapter', parent_location=self.course.location, display_name="Chapter 1", ) - section = ItemFactory.create( + section = BlockFactory.create( category='sequential', parent_location=chapter.location, due=datetime(2013, 9, 18, 11, 30, 00), display_name='Sequential 1', format='Homework' ) - self.math_vertical = ItemFactory.create( + self.math_vertical = BlockFactory.create( category='vertical', parent_location=section.location, display_name='Vertical with Mathjax HTML', ) - self.no_math_vertical = ItemFactory.create( + self.no_math_vertical = BlockFactory.create( category='vertical', parent_location=section.location, display_name='Vertical with No Mathjax HTML', @@ -3243,7 +3243,7 @@ def setUp(self): ("[mathjax]", "[/mathjax]"), ] for (i, (start_tag, end_tag)) in enumerate(MATHJAX_TAG_PAIRS): - math_html_block = ItemFactory.create( + math_html_block = BlockFactory.create( category='html', parent_location=self.math_vertical.location, display_name=f"HTML With Mathjax {i}", @@ -3251,7 +3251,7 @@ def setUp(self): ) self.math_html_usage_keys.append(math_html_block.location) - self.html_without_mathjax = ItemFactory.create( + self.html_without_mathjax = BlockFactory.create( category='html', parent_location=self.no_math_vertical.location, display_name="HTML Without Mathjax", @@ -3329,8 +3329,8 @@ def test_course_wide_resources(self, url_name, param, is_instructor, is_rendered css = ['https://testcdn.com/css/lib.min.css', '//testcdn.com/css/lib2.css', '/test.css'] course = CourseFactory.create(course_wide_js=js, course_wide_css=css) - chapter = ItemFactory.create(parent_location=course.location, category='chapter') - sequence = ItemFactory.create(parent_location=chapter.location, category='sequential', display_name='Sequence') + chapter = BlockFactory.create(parent_location=course.location, category='chapter') + sequence = BlockFactory.create(parent_location=chapter.location, category='sequential', display_name='Sequence') CourseOverview.load_from_module_store(course.id) CourseEnrollmentFactory(user=user, course_id=course.id) diff --git a/lms/djangoapps/courseware/testutils.py b/lms/djangoapps/courseware/testutils.py index fe510799d282..d55495f4aa3f 100644 --- a/lms/djangoapps/courseware/testutils.py +++ b/lms/djangoapps/courseware/testutils.py @@ -21,7 +21,7 @@ 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.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order from .field_overrides import OverrideModulestoreFieldData from .tests.helpers import MasqueradeMixin @@ -101,23 +101,23 @@ def setup_course(self, default_store=None): default_store = self.store.default_modulestore.get_modulestore_type() with self.store.default_store(default_store): self.course = CourseFactory.create(**self.course_options()) - chapter = ItemFactory.create(parent=self.course, category='chapter') - self.vertical_block = ItemFactory.create( + chapter = BlockFactory.create(parent=self.course, category='chapter') + self.vertical_block = BlockFactory.create( parent_location=chapter.location, category='vertical', display_name="Vertical" ) - self.html_block = ItemFactory.create( + self.html_block = BlockFactory.create( parent=self.vertical_block, category='html', data="
Test HTML Content
" ) - self.problem_block = ItemFactory.create( + self.problem_block = BlockFactory.create( parent=self.vertical_block, category='problem', display_name='Problem' ) - self.video_block = ItemFactory.create( + self.video_block = BlockFactory.create( parent=self.vertical_block, category='video', display_name='Video' diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index b51cc00a5982..59a65255deca 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -491,7 +491,7 @@ def _add_sequence_title_to_context(self, courseware_context): exceeds the length of the displayable items, default the position to the first element. """ - display_items = self.section.get_display_items() + display_items = self.section.get_children() if not display_items: return if self.section.position > len(display_items): @@ -565,7 +565,7 @@ def save_child_position(seq_block, child_name): """ child_name: url_name of the child """ - for position, child in enumerate(seq_block.get_display_items(), start=1): + for position, child in enumerate(seq_block.get_children(), start=1): if child.location.block_id == child_name: # Only save if position changed if position != seq_block.position: diff --git a/lms/djangoapps/discussion/django_comment_client/base/tests.py b/lms/djangoapps/discussion/django_comment_client/base/tests.py index 4ac9e6db12a0..ecff54355e33 100644 --- a/lms/djangoapps/discussion/django_comment_client/base/tests.py +++ b/lms/djangoapps/discussion/django_comment_client/base/tests.py @@ -55,7 +55,7 @@ from xmodule.modulestore.tests.django_utils import ( TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase, SharedModuleStoreTestCase, ) -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls from .event_transformers import ForumThreadViewedEventTransformer @@ -225,7 +225,7 @@ def set_up_course(self, module_count=0): # add some discussion modules for i in range(module_count): - ItemFactory.create( + BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id=f'id_module_{i}', @@ -2064,14 +2064,14 @@ def setUp(self): self.staff = UserFactory.create(is_staff=True) UserBasedRole(user=self.staff, role=CourseStaffRole.ROLE).add_course(self.course.id) CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id) - self.category = ItemFactory.create( + self.category = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id=self.CATEGORY_ID, discussion_category=self.PARENT_CATEGORY_NAME, discussion_target=self.CATEGORY_NAME, ) - self.team_category = ItemFactory.create( + self.team_category = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id=self.TEAM_CATEGORY_ID, diff --git a/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py b/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py index de78da7c844e..928d82d22a36 100644 --- a/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py +++ b/lms/djangoapps/discussion/django_comment_client/tests/test_utils.py @@ -51,7 +51,7 @@ from openedx.core.djangoapps.util.testing import ContentGroupTestCase from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, ToyCourseFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, ToyCourseFactory class DictionaryTestCase(TestCase): @@ -135,14 +135,14 @@ class CoursewareContextTestCase(ModuleStoreTestCase): def setUp(self): super().setUp() self.course = CourseFactory.create(org="TestX", number="101", display_name="Test Course") - self.discussion1 = ItemFactory.create( + self.discussion1 = BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id="discussion1", discussion_category="Chapter", discussion_target="Discussion 1" ) - self.discussion2 = ItemFactory.create( + self.discussion2 = BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id="discussion2", @@ -180,7 +180,7 @@ def test_empty_discussion_subcategory_title(self): Test that for empty subcategory inline discussion modules, the divider " / " is not rendered on a post or inline discussion topic label. """ - discussion = ItemFactory.create( + discussion = BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id="discussion", @@ -228,21 +228,21 @@ def setUp(self): super().setUp() self.course = CourseFactory.create(org='TestX', number='101', display_name='Test Course') - self.discussion = ItemFactory.create( + self.discussion = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='test_discussion_id', discussion_category='Chapter', discussion_target='Discussion 1' ) - self.discussion2 = ItemFactory.create( + self.discussion2 = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='test_discussion_id_2', discussion_category='Chapter 2', discussion_target='Discussion 2' ) - self.private_discussion = ItemFactory.create( + self.private_discussion = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='private_discussion_id', @@ -251,7 +251,7 @@ def setUp(self): visible_to_staff_only=True ) RequestCache.clear_all_namespaces() # clear the cache before the last course publish - self.bad_discussion = ItemFactory.create( + self.bad_discussion = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='bad_discussion_id', @@ -376,7 +376,7 @@ def setUp(self): def create_discussion(self, discussion_category, discussion_target, **kwargs): self.discussion_num += 1 - return ItemFactory.create( + return BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id=f"discussion{self.discussion_num}", diff --git a/lms/djangoapps/discussion/rest_api/tests/test_api.py b/lms/djangoapps/discussion/rest_api/tests/test_api.py index c1feb723b496..ab2b72214f13 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_api.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_api.py @@ -25,7 +25,7 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.partitions.partitions import Group, UserPartition from common.djangoapps.student.tests.factories import ( @@ -319,7 +319,7 @@ def make_discussion_xblock(self, topic_id, category, subcategory, **kwargs): """ Build a discussion xblock in self.course. """ - ItemFactory.create( + BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id=topic_id, @@ -4014,20 +4014,20 @@ def setUp(self) -> None: self.course = CourseFactory.create( discussion_topics={f"Course Wide Topic {idx}": {"id": f'course-wide-topic-{idx}'} for idx in range(10)} ) - self.chapter = ItemFactory.create( + self.chapter = BlockFactory.create( parent_location=self.course.location, category='chapter', display_name="Week 1", start=datetime(2015, 3, 1, tzinfo=UTC), ) - self.sequential = ItemFactory.create( + self.sequential = BlockFactory.create( parent_location=self.chapter.location, category='sequential', display_name="Lesson 1", start=datetime(2015, 3, 1, tzinfo=UTC), ) self.verticals = [ - ItemFactory.create( + BlockFactory.create( parent_location=self.sequential.location, category='vertical', display_name=f'vertical-{idx}', @@ -4035,7 +4035,7 @@ def setUp(self) -> None: ) for idx in range(10) ] - staff_only_unit = ItemFactory.create( + staff_only_unit = BlockFactory.create( parent_location=self.sequential.location, category='vertical', display_name='staff-vertical-1', diff --git a/lms/djangoapps/discussion/rest_api/tests/test_views.py b/lms/djangoapps/discussion/rest_api/tests/test_views.py index 2455d73e0e36..ade937a51e17 100644 --- a/lms/djangoapps/discussion/rest_api/tests/test_views.py +++ b/lms/djangoapps/discussion/rest_api/tests/test_views.py @@ -26,7 +26,7 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory @@ -746,7 +746,7 @@ def create_course(self, modules_count, module_store, topics): course_url = reverse("course_topics", kwargs={"course_id": str(course.id)}) # add some discussion xblocks for i in range(modules_count): - ItemFactory.create( + BlockFactory.create( parent_location=course.location, category='discussion', discussion_id=f'id_module_{i}', @@ -760,7 +760,7 @@ def make_discussion_xblock(self, topic_id, category, subcategory, **kwargs): """ Build a discussion xblock in self.course """ - ItemFactory.create( + BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id=topic_id, @@ -882,19 +882,19 @@ def test_new_course_structure_response(self): Tests whether the new structure is available on old topics API (For mobile compatibility) """ - chapter = ItemFactory.create( + chapter = BlockFactory.create( parent_location=self.course.location, category='chapter', display_name="Week 1", start=datetime(2015, 3, 1, tzinfo=UTC), ) - sequential = ItemFactory.create( + sequential = BlockFactory.create( parent_location=chapter.location, category='sequential', display_name="Lesson 1", start=datetime(2015, 3, 1, tzinfo=UTC), ) - ItemFactory.create( + BlockFactory.create( parent_location=sequential.location, category='vertical', display_name='vertical', @@ -942,20 +942,20 @@ def setUp(self) -> None: "usage_key": None, }} ) - self.chapter = ItemFactory.create( + self.chapter = BlockFactory.create( parent_location=self.course.location, category='chapter', display_name="Week 1", start=datetime(2015, 3, 1, tzinfo=UTC), ) - self.sequential = ItemFactory.create( + self.sequential = BlockFactory.create( parent_location=self.chapter.location, category='sequential', display_name="Lesson 1", start=datetime(2015, 3, 1, tzinfo=UTC), ) self.verticals = [ - ItemFactory.create( + BlockFactory.create( parent_location=self.sequential.location, category='vertical', display_name='vertical', @@ -2747,7 +2747,7 @@ def _create_divided_discussions(self): divided_course_wide_discussions = ['Topic B', ] divided_discussions = divided_inline_discussions + divided_course_wide_discussions - ItemFactory.create( + BlockFactory.create( parent=self.course, category='discussion', discussion_id=topic_name_to_id(self.course, 'Topic A'), @@ -2971,7 +2971,7 @@ def test_update_inline_discussion_settings(self): self._assert_current_settings(expected_response) now = datetime.now() - ItemFactory.create( + BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='Topic_A', diff --git a/lms/djangoapps/discussion/tests/test_signals.py b/lms/djangoapps/discussion/tests/test_signals.py index 6730ac40da38..a835a528daa7 100644 --- a/lms/djangoapps/discussion/tests/test_signals.py +++ b/lms/djangoapps/discussion/tests/test_signals.py @@ -8,7 +8,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import ( CourseFactory, - ItemFactory + BlockFactory ) from lms.djangoapps.discussion.signals.handlers import ENABLE_FORUM_NOTIFICATIONS_FOR_SITE_KEY @@ -86,7 +86,7 @@ def test_discussion_id_map_updates_on_publish(self): # create discussion block RequestCache().clear() discussion_id = 'discussion1' - discussion_block = ItemFactory.create( + discussion_block = BlockFactory.create( parent_location=course.location, category="discussion", discussion_id=discussion_id, diff --git a/lms/djangoapps/discussion/tests/test_views.py b/lms/djangoapps/discussion/tests/test_views.py index 612113c43ec7..ffb6c5855a36 100644 --- a/lms/djangoapps/discussion/tests/test_views.py +++ b/lms/djangoapps/discussion/tests/test_views.py @@ -25,7 +25,7 @@ ) from xmodule.modulestore.tests.factories import ( CourseFactory, - ItemFactory, + BlockFactory, check_mongo_calls ) @@ -1357,7 +1357,7 @@ def setUp(self): ) self.student = UserFactory.create() CourseEnrollmentFactory(user=self.student, course_id=self.course.id) - self.discussion1 = ItemFactory.create( + self.discussion1 = BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id="discussion1", @@ -1897,7 +1897,7 @@ def create_divided_discussions(self): divided_discussions = divided_inline_discussions + divided_course_wide_discussions # inline discussion - ItemFactory.create( + BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id=topic_name_to_id(self.course, "Topic A"), @@ -2068,7 +2068,7 @@ def test_update_inline_discussion_settings(self): RequestCache.clear_all_namespaces() now = datetime.now() # inline discussion - ItemFactory.create( + BlockFactory.create( parent_location=self.course.location, category="discussion", discussion_id="Topic_A", @@ -2208,7 +2208,7 @@ def setUp(self): # pylint: disable=arguments-differ self.staff = UserFactory.create(is_staff=True) UserBasedRole(user=self.staff, role=CourseStaffRole.ROLE).add_course(self.course.id) - self.category = ItemFactory.create( + self.category = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id=self.CATEGORY_ID, diff --git a/lms/djangoapps/edxnotes/tests.py b/lms/djangoapps/edxnotes/tests.py index 1baed0d6cbca..a0f90f7ea026 100644 --- a/lms/djangoapps/edxnotes/tests.py +++ b/lms/djangoapps/edxnotes/tests.py @@ -31,7 +31,7 @@ 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.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order from xmodule.tabs import CourseTab # lint-amnesty, pylint: disable=wrong-import-order from xmodule.tests.helpers import StubUserService # lint-amnesty, pylint: disable=wrong-import-order @@ -205,19 +205,20 @@ def setUp(self): with self.store.default_store(ModuleStoreEnum.Type.split): ApplicationFactory(name="edx-notes") self.course = CourseFactory.create() - self.chapter = ItemFactory.create(category="chapter", parent_location=self.course.location) - self.chapter_2 = ItemFactory.create(category="chapter", parent_location=self.course.location) - self.sequential = ItemFactory.create(category="sequential", parent_location=self.chapter.location) - self.vertical = ItemFactory.create(category="vertical", parent_location=self.sequential.location) - self.html_block_1 = ItemFactory.create(category="html", parent_location=self.vertical.location) - self.html_block_2 = ItemFactory.create(category="html", parent_location=self.vertical.location) - self.vertical_with_container = ItemFactory.create( + self.chapter = BlockFactory.create(category="chapter", parent_location=self.course.location) + self.chapter_2 = BlockFactory.create(category="chapter", parent_location=self.course.location) + self.sequential = BlockFactory.create(category="sequential", parent_location=self.chapter.location) + self.vertical = BlockFactory.create(category="vertical", parent_location=self.sequential.location) + self.html_block_1 = BlockFactory.create(category="html", parent_location=self.vertical.location) + self.html_block_2 = BlockFactory.create(category="html", parent_location=self.vertical.location) + self.vertical_with_container = BlockFactory.create( category='vertical', parent_location=self.sequential.location ) - self.child_container = ItemFactory.create( + self.child_container = BlockFactory.create( category='split_test', parent_location=self.vertical_with_container.location) - self.child_vertical = ItemFactory.create(category='vertical', parent_location=self.child_container.location) - self.child_html_block = ItemFactory.create(category="html", parent_location=self.child_vertical.location) + self.child_vertical = BlockFactory.create( + category='vertical', parent_location=self.child_container.location) + self.child_html_block = BlockFactory.create(category="html", parent_location=self.child_vertical.location) # Read again so that children lists are accurate self.course = self.store.get_item(self.course.location) @@ -818,7 +819,7 @@ def test_get_course_position_no_chapter(self): """ mock_course_block = MagicMock() mock_course_block.position = 3 - mock_course_block.get_display_items.return_value = [] + mock_course_block.get_children.return_value = [] assert helpers.get_course_position(mock_course_block) is None def test_get_course_position_to_chapter(self): @@ -832,7 +833,7 @@ def test_get_course_position_to_chapter(self): mock_chapter.url_name = 'chapter_url_name' mock_chapter.display_name_with_default = 'Test Chapter Display Name' - mock_course_block.get_display_items.return_value = [mock_chapter] + mock_course_block.get_children.return_value = [mock_chapter] assert helpers.get_course_position(mock_course_block) == { 'display_name': 'Test Chapter Display Name', @@ -844,7 +845,7 @@ def test_get_course_position_no_section(self): Returns `None` if no section found. """ mock_course_block = MagicMock(id=self.course.id, position=None) - mock_course_block.get_display_items.return_value = [MagicMock()] + mock_course_block.get_children.return_value = [MagicMock()] assert helpers.get_course_position(mock_course_block) is None def test_get_course_position_to_section(self): @@ -856,14 +857,14 @@ def test_get_course_position_to_section(self): mock_chapter = MagicMock() mock_chapter.url_name = 'chapter_url_name' - mock_course_block.get_display_items.return_value = [mock_chapter] + mock_course_block.get_children.return_value = [mock_chapter] mock_section = MagicMock() mock_section.url_name = 'section_url_name' mock_section.display_name_with_default = 'Test Section Display Name' - mock_chapter.get_display_items.return_value = [mock_section] - mock_section.get_display_items.return_value = [MagicMock()] + mock_chapter.get_children.return_value = [mock_section] + mock_section.get_children.return_value = [MagicMock()] assert helpers.get_course_position(mock_course_block) == { 'display_name': 'Test Section Display Name', diff --git a/lms/djangoapps/gating/tests/test_api.py b/lms/djangoapps/gating/tests/test_api.py index 6ddd4484c529..326ea9124cf9 100644 --- a/lms/djangoapps/gating/tests/test_api.py +++ b/lms/djangoapps/gating/tests/test_api.py @@ -13,7 +13,7 @@ from lms.djangoapps.gating.api import evaluate_prerequisite from openedx.core.lib.gating import api as gating_api from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order class GatingTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase): @@ -40,19 +40,19 @@ def setUp(self): self.update_course(self.course, 0) # create chapter - self.chapter1 = ItemFactory.create( + self.chapter1 = BlockFactory.create( parent_location=self.course.location, category='chapter', display_name='untitled chapter 1' ) # create sequentials - self.seq1 = ItemFactory.create( + self.seq1 = BlockFactory.create( parent_location=self.chapter1.location, category='sequential', display_name='gating sequential' ) - self.seq2 = ItemFactory.create( + self.seq2 = BlockFactory.create( parent_location=self.chapter1.location, category='sequential', display_name='gated sequential' diff --git a/lms/djangoapps/gating/tests/test_integration.py b/lms/djangoapps/gating/tests/test_integration.py index 0371db96b20b..ffa9ef243f95 100644 --- a/lms/djangoapps/gating/tests/test_integration.py +++ b/lms/djangoapps/gating/tests/test_integration.py @@ -12,7 +12,7 @@ from milestones.tests.utils import MilestonesTestCaseMixin from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import UserFactory from lms.djangoapps.courseware.access import has_access @@ -69,28 +69,28 @@ def set_up_course(cls): course.save() # create chapter - cls.chapter1 = ItemFactory.create( + cls.chapter1 = BlockFactory.create( parent=course, category='chapter', display_name='chapter 1' ) # create sequentials - cls.seq1 = ItemFactory.create( + cls.seq1 = BlockFactory.create( parent=cls.chapter1, category='sequential', display_name='gating sequential 1', graded=True, format='Homework', ) - cls.seq2 = ItemFactory.create( + cls.seq2 = BlockFactory.create( parent=cls.chapter1, category='sequential', display_name='gated sequential 2', graded=True, format='Homework', ) - cls.seq3 = ItemFactory.create( + cls.seq3 = BlockFactory.create( parent=cls.chapter1, category='sequential', display_name='sequential 3', @@ -99,7 +99,7 @@ def set_up_course(cls): ) # create problem - cls.gating_prob1 = ItemFactory.create( + cls.gating_prob1 = BlockFactory.create( parent=cls.seq1, category='problem', display_name='gating problem 1', @@ -107,7 +107,7 @@ def set_up_course(cls): # add a discussion block to the prerequisite subsection # this should give us ability to test gating with blocks # which needs to be excluded from completion tracking - ItemFactory.create( + BlockFactory.create( parent=cls.seq1, category="discussion", discussion_id="discussion 1", @@ -115,12 +115,12 @@ def set_up_course(cls): discussion_target="discussion target", ) - cls.gated_prob2 = ItemFactory.create( + cls.gated_prob2 = BlockFactory.create( parent=cls.seq2, category='problem', display_name='gated problem 2', ) - cls.prob3 = ItemFactory.create( + cls.prob3 = BlockFactory.create( parent=cls.seq3, category='problem', display_name='problem 3', diff --git a/lms/djangoapps/grades/rest_api/v1/tests/mixins.py b/lms/djangoapps/grades/rest_api/v1/tests/mixins.py index 54851fecc3d0..e5e7f269e3a2 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/mixins.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/mixins.py @@ -7,7 +7,7 @@ from pytz import UTC from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from common.djangoapps.student.tests.factories import GlobalStaffFactory @@ -127,7 +127,7 @@ def _create_test_course_with_default_grading_policy(cls, display_name, run): course = CourseFactory.create(display_name=display_name, run=run) _ = CourseOverviewFactory.create(id=course.id) - chapter = ItemFactory.create( + chapter = BlockFactory.create( category='chapter', parent_location=course.location, display_name="Chapter 1", @@ -136,7 +136,7 @@ def _create_test_course_with_default_grading_policy(cls, display_name, run): # A section is not considered if the student answers less than "min_count" problems for grading_type, min_count in (("Homework", 12), ("Lab", 12), ("Midterm Exam", 1), ("Final Exam", 1)): for num in range(min_count): - section = ItemFactory.create( + section = BlockFactory.create( category='sequential', parent_location=chapter.location, due=datetime(2017, 12, 18, 11, 30, 00), @@ -144,12 +144,12 @@ def _create_test_course_with_default_grading_policy(cls, display_name, run): format=grading_type, graded=True, ) - vertical = ItemFactory.create( + vertical = BlockFactory.create( category='vertical', parent_location=section.location, display_name=f'Vertical {grading_type} {num}', ) - ItemFactory.create( + BlockFactory.create( category='problem', parent_location=vertical.location, display_name=f'Problem {grading_type} {num}', diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py index 0ff96467e7d6..a6adfc3a3c21 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_gradebook_views.py @@ -19,7 +19,7 @@ from rest_framework import status from rest_framework.test import APITestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.student.roles import ( @@ -80,54 +80,54 @@ def initialize_course(cls, course): course.grade_cutoffs = { "Pass": 0.5, } - cls.section = ItemFactory.create( + cls.section = BlockFactory.create( parent_location=course.location, category="chapter", ) - cls.subsection1 = ItemFactory.create( + cls.subsection1 = BlockFactory.create( parent_location=cls.section.location, category="sequential", ) - unit1 = ItemFactory.create( + unit1 = BlockFactory.create( parent_location=cls.subsection1.location, category="vertical", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit1.location, category="video", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit1.location, category="problem", ) - cls.subsection2 = ItemFactory.create( + cls.subsection2 = BlockFactory.create( parent_location=cls.section.location, category="sequential", ) - unit2 = ItemFactory.create( + unit2 = BlockFactory.create( parent_location=cls.subsection2.location, category="vertical", ) - unit3 = ItemFactory.create( + unit3 = BlockFactory.create( parent_location=cls.subsection2.location, category="vertical", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit3.location, category="video", ) - ItemFactory.create( + BlockFactory.create( parent_location=unit3.location, category="video", ) - cls.homework = ItemFactory.create( + cls.homework = BlockFactory.create( parent_location=cls.section.location, category="sequential", graded=True, format='Homework', ) - cls.midterm = ItemFactory.create( + cls.midterm = BlockFactory.create( parent_location=cls.section.location, category="sequential", graded=True, @@ -296,19 +296,19 @@ def setUpClass(cls): cls.course_key = cls.course.id cls.course_overview = CourseOverviewFactory.create(id=cls.course.id) - cls.chapter_1 = ItemFactory.create( + cls.chapter_1 = BlockFactory.create( category='chapter', parent_location=cls.course.location, display_name="Chapter 1", ) - cls.chapter_2 = ItemFactory.create( + cls.chapter_2 = BlockFactory.create( category='chapter', parent_location=cls.course.location, display_name="Chapter 2", ) cls.subsections = { cls.chapter_1.location: [ - ItemFactory.create( + BlockFactory.create( category='sequential', parent_location=cls.chapter_1.location, due=datetime(2017, 12, 18, 11, 30, 00), @@ -316,7 +316,7 @@ def setUpClass(cls): format='Homework', graded=True, ), - ItemFactory.create( + BlockFactory.create( category='sequential', parent_location=cls.chapter_1.location, due=datetime(2017, 12, 18, 11, 30, 00), @@ -326,7 +326,7 @@ def setUpClass(cls): ), ], cls.chapter_2.location: [ - ItemFactory.create( + BlockFactory.create( category='sequential', parent_location=cls.chapter_2.location, due=datetime(2017, 12, 18, 11, 30, 00), @@ -334,7 +334,7 @@ def setUpClass(cls): format='Homework', graded=True, ), - ItemFactory.create( + BlockFactory.create( category='sequential', parent_location=cls.chapter_2.location, due=datetime(2017, 12, 18, 11, 30, 00), @@ -347,7 +347,7 @@ def setUpClass(cls): # Data about graded subsections visible to staff only # should not be exposed via the gradebook API - cls.hidden_subsection = ItemFactory.create( + cls.hidden_subsection = BlockFactory.create( parent_location=cls.chapter_1.location, category='sequential', graded=True, @@ -2175,7 +2175,7 @@ def test_with_unauthorized_user(self): @patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False}) def test_get_override_for_unreleased_block(self): self.login_course_staff() - unreleased_subsection = ItemFactory.create( + unreleased_subsection = BlockFactory.create( parent_location=self.chapter_1.location, category='sequential', graded=True, diff --git a/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py b/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py index 653a5bdd6363..aa5f526332e5 100644 --- a/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py +++ b/lms/djangoapps/grades/rest_api/v1/tests/test_grading_policy_view.py @@ -10,7 +10,7 @@ from pytz import UTC from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory from common.djangoapps.student.tests.factories import GlobalStaffFactory from common.djangoapps.student.tests.factories import StaffFactory @@ -42,7 +42,7 @@ def create_course_data(cls): # lint-amnesty, pylint: disable=missing-function-d ) cls.course_id = str(cls.course.id) with cls.store.bulk_operations(cls.course.id, emit_signals=False): - cls.sequential = ItemFactory.create( + cls.sequential = BlockFactory.create( category="sequential", parent_location=cls.course.location, display_name="Lesson 1", @@ -53,7 +53,7 @@ def create_course_data(cls): # lint-amnesty, pylint: disable=missing-function-d factory = MultipleChoiceResponseXMLFactory() args = {'choices': [False, True, False]} problem_xml = factory.build_xml(**args) - cls.problem = ItemFactory.create( + cls.problem = BlockFactory.create( category="problem", parent_location=cls.sequential.location, display_name="Problem 1", @@ -61,13 +61,13 @@ def create_course_data(cls): # lint-amnesty, pylint: disable=missing-function-d data=problem_xml, ) - cls.video = ItemFactory.create( + cls.video = BlockFactory.create( category="video", parent_location=cls.sequential.location, display_name="Video 1", ) - cls.html = ItemFactory.create( + cls.html = BlockFactory.create( category="html", parent_location=cls.sequential.location, display_name="HTML 1", diff --git a/lms/djangoapps/grades/tests/base.py b/lms/djangoapps/grades/tests/base.py index 19cf45bfcc2b..e9397d0cf16f 100644 --- a/lms/djangoapps/grades/tests/base.py +++ b/lms/djangoapps/grades/tests/base.py @@ -5,7 +5,7 @@ from crum import set_current_request from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory from common.djangoapps.student.models import CourseEnrollment @@ -26,19 +26,19 @@ def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() with cls.store.bulk_operations(cls.course.id): - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, category="chapter", display_name="Test Chapter" ) - cls.sequence = ItemFactory.create( + cls.sequence = BlockFactory.create( parent=cls.chapter, category='sequential', display_name="Test Sequential X with an & Ampersand", graded=True, format="Homework" ) - cls.vertical = ItemFactory.create( + cls.vertical = BlockFactory.create( parent=cls.sequence, category='vertical', display_name='Test Vertical 1' @@ -48,20 +48,20 @@ def setUpClass(cls): choices=[False, False, True, False], choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3'] ) - cls.problem = ItemFactory.create( + cls.problem = BlockFactory.create( parent=cls.vertical, category="problem", display_name="Test Problem", data=problem_xml ) - cls.sequence2 = ItemFactory.create( + cls.sequence2 = BlockFactory.create( parent=cls.chapter, category='sequential', display_name="Test Sequential A", graded=True, format="Homework" ) - cls.problem2 = ItemFactory.create( + cls.problem2 = BlockFactory.create( parent=cls.sequence2, category="problem", display_name="Test Problem 2", @@ -69,7 +69,7 @@ def setUpClass(cls): ) # AED 2017-06-19: make cls.sequence belong to multiple parents, # so we can test that DAGs with this shape are handled correctly. - cls.chapter_2 = ItemFactory.create( + cls.chapter_2 = BlockFactory.create( parent=cls.course, category='chapter', display_name='Test Chapter 2' diff --git a/lms/djangoapps/grades/tests/integration/test_access.py b/lms/djangoapps/grades/tests/integration/test_access.py index 9149fe64728f..380962b19e99 100644 --- a/lms/djangoapps/grades/tests/integration/test_access.py +++ b/lms/djangoapps/grades/tests/integration/test_access.py @@ -14,7 +14,7 @@ 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.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order from ...subsection_grade_factory import SubsectionGradeFactory @@ -30,19 +30,19 @@ def setUpClass(cls): super().setUpClass() cls.store = modulestore() cls.course = CourseFactory.create() - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, category="chapter", display_name="Test Chapter" ) - cls.sequence = ItemFactory.create( + cls.sequence = BlockFactory.create( parent=cls.chapter, category='sequential', display_name="Test Sequential 1", graded=True, format="Homework" ) - cls.vertical = ItemFactory.create( + cls.vertical = BlockFactory.create( parent=cls.sequence, category='vertical', display_name='Test Vertical 1' @@ -52,7 +52,7 @@ def setUpClass(cls): choices=[False, False, True, False], choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3'] ) - cls.problem = ItemFactory.create( + cls.problem = BlockFactory.create( parent=cls.vertical, category="problem", display_name="p1", @@ -60,7 +60,7 @@ def setUpClass(cls): metadata={'weight': 2} ) - cls.problem_2 = ItemFactory.create( + cls.problem_2 = BlockFactory.create( parent=cls.vertical, category="problem", display_name="p2", diff --git a/lms/djangoapps/grades/tests/integration/test_events.py b/lms/djangoapps/grades/tests/integration/test_events.py index f9b2ba454583..868b55eeae67 100644 --- a/lms/djangoapps/grades/tests/integration/test_events.py +++ b/lms/djangoapps/grades/tests/integration/test_events.py @@ -15,7 +15,7 @@ from openedx.core.djangolib.testing.utils import get_mock_request from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order from ... import events @@ -34,19 +34,19 @@ def reset_course(cls): """ with cls.store.default_store(ModuleStoreEnum.Type.split): cls.course = CourseFactory.create() - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, category="chapter", display_name="Test Chapter" ) - cls.sequence = ItemFactory.create( + cls.sequence = BlockFactory.create( parent=cls.chapter, category='sequential', display_name="Test Sequential 1", graded=True, format="Homework" ) - cls.vertical = ItemFactory.create( + cls.vertical = BlockFactory.create( parent=cls.sequence, category='vertical', display_name='Test Vertical 1' @@ -56,7 +56,7 @@ def reset_course(cls): choices=[False, False, True, False], choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3'] ) - cls.problem = ItemFactory.create( + cls.problem = BlockFactory.create( parent=cls.vertical, category="problem", display_name="p1", diff --git a/lms/djangoapps/grades/tests/integration/test_problems.py b/lms/djangoapps/grades/tests/integration/test_problems.py index fc187b22618e..36c54bec86e9 100644 --- a/lms/djangoapps/grades/tests/integration/test_problems.py +++ b/lms/djangoapps/grades/tests/integration/test_problems.py @@ -10,7 +10,7 @@ from xmodule.modulestore.tests.django_utils import ( TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase, SharedModuleStoreTestCase, ) -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.modulestore.tests.utils import TEST_DATA_DIR from xmodule.modulestore.xml_importer import import_course_from_xml from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory @@ -118,18 +118,18 @@ def setUp(self): super().setUp() self.course = CourseFactory.create() with self.store.bulk_operations(self.course.id): - self.chapter = ItemFactory.create( + self.chapter = BlockFactory.create( parent=self.course, category="chapter", display_name="Test Chapter" ) - self.sequence = ItemFactory.create( + self.sequence = BlockFactory.create( parent=self.chapter, category='sequential', display_name="Test Sequential 1", graded=True ) - self.vertical = ItemFactory.create( + self.vertical = BlockFactory.create( parent=self.sequence, category='vertical', display_name='Test Vertical 1' @@ -162,7 +162,7 @@ def _add_problem_with_alterations(self, alterations): """ metadata = self._get_altered_metadata(alterations) - ItemFactory.create( + BlockFactory.create( parent=self.vertical, category="problem", display_name="problem", @@ -223,14 +223,14 @@ def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() with cls.store.bulk_operations(cls.course.id): - cls.chapter = ItemFactory.create(parent=cls.course, category="chapter", display_name="chapter") - cls.sequential = ItemFactory.create(parent=cls.chapter, category="sequential", display_name="sequential") - cls.vertical = ItemFactory.create(parent=cls.sequential, category="vertical", display_name="vertical1") + cls.chapter = BlockFactory.create(parent=cls.course, category="chapter", display_name="chapter") + cls.sequential = BlockFactory.create(parent=cls.chapter, category="sequential", display_name="sequential") + cls.vertical = BlockFactory.create(parent=cls.sequential, category="vertical", display_name="vertical1") problem_xml = cls._create_problem_xml() cls.problems = [] for i in range(2): cls.problems.append( - ItemFactory.create( + BlockFactory.create( parent=cls.vertical, category="problem", display_name=f"problem_{i}", diff --git a/lms/djangoapps/grades/tests/test_api.py b/lms/djangoapps/grades/tests/test_api.py index 62c92ad5d3df..771a0637ef39 100644 --- a/lms/djangoapps/grades/tests/test_api.py +++ b/lms/djangoapps/grades/tests/test_api.py @@ -9,7 +9,7 @@ from lms.djangoapps.grades import api from lms.djangoapps.grades.models import PersistentSubsectionGrade, PersistentSubsectionGradeOverride from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order @ddt.ddt @@ -41,7 +41,7 @@ def tearDownClass(cls): def setUp(self): super().setUp() self.course = CourseFactory.create(org='edX', number='DemoX', display_name='Demo_Course', run='Spring2019') - self.subsection = ItemFactory.create(parent=self.course, category="sequential", display_name="Subsection") + self.subsection = BlockFactory.create(parent=self.course, category="sequential", display_name="Subsection") self.grade = PersistentSubsectionGrade.update_or_create_grade( user_id=self.user.id, course_id=self.course.id, diff --git a/lms/djangoapps/grades/tests/test_course_grade.py b/lms/djangoapps/grades/tests/test_course_grade.py index 78de082e953c..8ac66aad28ab 100644 --- a/lms/djangoapps/grades/tests/test_course_grade.py +++ b/lms/djangoapps/grades/tests/test_course_grade.py @@ -4,7 +4,7 @@ import ddt from crum import set_current_request from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.tests.factories import UserFactory @@ -74,20 +74,20 @@ def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() with cls.store.bulk_operations(cls.course.id): - cls.a = ItemFactory.create(parent=cls.course, category="chapter", display_name="a") - cls.b = ItemFactory.create(parent=cls.a, category="sequential", display_name="b") - cls.c = ItemFactory.create(parent=cls.a, category="sequential", display_name="c") - cls.d = ItemFactory.create(parent=cls.b, category="vertical", display_name="d") - cls.e = ItemFactory.create(parent=cls.b, category="vertical", display_name="e") - cls.f = ItemFactory.create(parent=cls.b, category="vertical", display_name="f") - cls.g = ItemFactory.create(parent=cls.c, category="vertical", display_name="g") - cls.h = ItemFactory.create(parent=cls.d, category="problem", display_name="h") - cls.i = ItemFactory.create(parent=cls.d, category="problem", display_name="i") - cls.j = ItemFactory.create(parent=cls.e, category="problem", display_name="j") - cls.k = ItemFactory.create(parent=cls.e, category="html", display_name="k") - cls.l = ItemFactory.create(parent=cls.e, category="problem", display_name="l") - cls.m = ItemFactory.create(parent=cls.f, category="html", display_name="m") - cls.n = ItemFactory.create(parent=cls.g, category="problem", display_name="n") + cls.a = BlockFactory.create(parent=cls.course, category="chapter", display_name="a") + cls.b = BlockFactory.create(parent=cls.a, category="sequential", display_name="b") + cls.c = BlockFactory.create(parent=cls.a, category="sequential", display_name="c") + cls.d = BlockFactory.create(parent=cls.b, category="vertical", display_name="d") + cls.e = BlockFactory.create(parent=cls.b, category="vertical", display_name="e") + cls.f = BlockFactory.create(parent=cls.b, category="vertical", display_name="f") + cls.g = BlockFactory.create(parent=cls.c, category="vertical", display_name="g") + cls.h = BlockFactory.create(parent=cls.d, category="problem", display_name="h") + cls.i = BlockFactory.create(parent=cls.d, category="problem", display_name="i") + cls.j = BlockFactory.create(parent=cls.e, category="problem", display_name="j") + cls.k = BlockFactory.create(parent=cls.e, category="html", display_name="k") + cls.l = BlockFactory.create(parent=cls.e, category="problem", display_name="l") + cls.m = BlockFactory.create(parent=cls.f, category="html", display_name="m") + cls.n = BlockFactory.create(parent=cls.g, category="problem", display_name="n") cls.request = get_mock_request(UserFactory()) CourseEnrollment.enroll(cls.request.user, cls.course.id) diff --git a/lms/djangoapps/grades/tests/test_services.py b/lms/djangoapps/grades/tests/test_services.py index 459cf6d08c59..07a77ff13f13 100644 --- a/lms/djangoapps/grades/tests/test_services.py +++ b/lms/djangoapps/grades/tests/test_services.py @@ -15,7 +15,7 @@ from lms.djangoapps.grades.models import PersistentSubsectionGrade, PersistentSubsectionGradeOverride from lms.djangoapps.grades.services import GradesService from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order from ..constants import ScoreDatabaseTableEnum @@ -42,8 +42,8 @@ def setUp(self): super().setUp() self.service = GradesService() self.course = CourseFactory.create(org='edX', number='DemoX', display_name='Demo_Course', run='Spring2019') - self.subsection = ItemFactory.create(parent=self.course, category="sequential", display_name="Subsection") - self.subsection_without_grade = ItemFactory.create( + self.subsection = BlockFactory.create(parent=self.course, category="sequential", display_name="Subsection") + self.subsection_without_grade = BlockFactory.create( parent=self.course, category="sequential", display_name="Subsection without grade" diff --git a/lms/djangoapps/grades/tests/test_tasks.py b/lms/djangoapps/grades/tests/test_tasks.py index 94b75fa680a1..4c4f60d731ea 100644 --- a/lms/djangoapps/grades/tests/test_tasks.py +++ b/lms/djangoapps/grades/tests/test_tasks.py @@ -16,7 +16,7 @@ from edx_toggles.toggles.testutils import override_waffle_flag from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls from common.djangoapps.student.models import CourseEnrollment, anonymous_id_for_user from common.djangoapps.student.tests.factories import UserFactory @@ -55,13 +55,13 @@ def set_up_course(self, create_multiple_subsections=False, course_end=None): end=course_end ) - self.chapter = ItemFactory.create(parent=self.course, category="chapter", display_name="Chapter") - self.sequential = ItemFactory.create(parent=self.chapter, category='sequential', display_name="Sequential1") - self.problem = ItemFactory.create(parent=self.sequential, category='problem', display_name='Problem') + self.chapter = BlockFactory.create(parent=self.course, category="chapter", display_name="Chapter") + self.sequential = BlockFactory.create(parent=self.chapter, category='sequential', display_name="Sequential1") + self.problem = BlockFactory.create(parent=self.sequential, category='problem', display_name='Problem') if create_multiple_subsections: - seq2 = ItemFactory.create(parent=self.chapter, category='sequential') - ItemFactory.create(parent=seq2, category='problem') + seq2 = BlockFactory.create(parent=self.chapter, category='sequential') + BlockFactory.create(parent=seq2, category='problem') self.frozen_now_datetime = datetime.now().replace(tzinfo=pytz.UTC) self.frozen_now_timestamp = to_timestamp(self.frozen_now_datetime) @@ -174,11 +174,11 @@ def test_query_counts_dont_change_with_more_content(self, default_store, num_mon num_problems = 10 for _ in range(num_problems): - ItemFactory.create(parent=self.sequential, category='problem') + BlockFactory.create(parent=self.sequential, category='problem') num_sequentials = 10 for _ in range(num_sequentials): - ItemFactory.create(parent=self.chapter, category='sequential') + BlockFactory.create(parent=self.chapter, category='sequential') with check_mongo_calls(num_mongo_calls): with self.assertNumQueries(num_sql_calls): @@ -187,8 +187,8 @@ def test_query_counts_dont_change_with_more_content(self, default_store, num_mon @patch('lms.djangoapps.grades.signals.signals.SUBSECTION_SCORE_CHANGED.send') def test_other_inaccessible_subsection(self, mock_subsection_signal): self.set_up_course() - accessible_seq = ItemFactory.create(parent=self.chapter, category='sequential') - inaccessible_seq = ItemFactory.create(parent=self.chapter, category='sequential', visible_to_staff_only=True) + accessible_seq = BlockFactory.create(parent=self.chapter, category='sequential') + inaccessible_seq = BlockFactory.create(parent=self.chapter, category='sequential', visible_to_staff_only=True) # Update problem to have 2 additional sequential parents. # So in total, 3 sequential parents, with one inaccessible. diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index 3f8848207355..8822b6aac7bc 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -35,7 +35,7 @@ from xmodule.modulestore.tests.django_utils import ( TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase, SharedModuleStoreTestCase, ) -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory @@ -360,14 +360,14 @@ class TestInstructorAPIDenyLevels(SharedModuleStoreTestCase, LoginEnrollmentTest def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, category='chapter', display_name="Chapter", publish_item=True, start=datetime.datetime(2018, 3, 10, tzinfo=UTC), ) - cls.sequential = ItemFactory.create( + cls.sequential = BlockFactory.create( parent=cls.chapter, category='sequential', display_name="Lesson", @@ -375,14 +375,14 @@ def setUpClass(cls): start=datetime.datetime(2018, 3, 10, tzinfo=UTC), metadata={'graded': True, 'format': 'Homework'}, ) - cls.vertical = ItemFactory.create( + cls.vertical = BlockFactory.create( parent=cls.sequential, category='vertical', display_name='Subsection', publish_item=True, start=datetime.datetime(2018, 3, 10, tzinfo=UTC), ) - cls.problem = ItemFactory.create( + cls.problem = BlockFactory.create( category="problem", parent=cls.vertical, display_name="A Problem Block", @@ -3105,27 +3105,27 @@ def setUpClass(cls): cls.course_with_invalid_ee = CourseFactory.create(entrance_exam_id='invalid_exam') with cls.store.bulk_operations(cls.course.id, emit_signals=False): - cls.entrance_exam = ItemFactory.create( + cls.entrance_exam = BlockFactory.create( parent=cls.course, category='chapter', display_name='Entrance exam' ) - subsection = ItemFactory.create( + subsection = BlockFactory.create( parent=cls.entrance_exam, category='sequential', display_name='Subsection 1' ) - vertical = ItemFactory.create( + vertical = BlockFactory.create( parent=subsection, category='vertical', display_name='Vertical 1' ) - cls.ee_problem_1 = ItemFactory.create( + cls.ee_problem_1 = BlockFactory.create( parent=vertical, category="problem", display_name="Exam Problem - Problem 1" ) - cls.ee_problem_2 = ItemFactory.create( + cls.ee_problem_2 = BlockFactory.create( parent=vertical, category="problem", display_name="Exam Problem - Problem 2" @@ -3938,15 +3938,15 @@ def setUpClass(cls): cls.due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=UTC) with cls.store.bulk_operations(cls.course.id, emit_signals=False): - cls.week1 = ItemFactory.create(due=cls.due) - cls.week2 = ItemFactory.create(due=cls.due) - cls.week3 = ItemFactory.create() # No due date + cls.week1 = BlockFactory.create(due=cls.due) + cls.week2 = BlockFactory.create(due=cls.due) + cls.week3 = BlockFactory.create() # No due date cls.course.children = [ str(cls.week1.location), str(cls.week2.location), str(cls.week3.location) ] - cls.homework = ItemFactory.create( + cls.homework = BlockFactory.create( parent_location=cls.week1.location, due=cls.due ) @@ -4120,15 +4120,15 @@ def setUp(self): self.due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=UTC) with self.store.bulk_operations(self.course.id, emit_signals=False): - self.week1 = ItemFactory.create(due=self.due) - self.week2 = ItemFactory.create(due=self.due) - self.week3 = ItemFactory.create() # No due date + self.week1 = BlockFactory.create(due=self.due) + self.week2 = BlockFactory.create(due=self.due) + self.week3 = BlockFactory.create() # No due date self.course.children = [ self.week1.location, self.week2.location, self.week3.location ] - self.homework = ItemFactory.create( + self.homework = BlockFactory.create( parent_location=self.week1.location, due=self.due ) diff --git a/lms/djangoapps/instructor/tests/test_enrollment.py b/lms/djangoapps/instructor/tests/test_enrollment.py index ca38b5ce26c5..c55b18576cb9 100644 --- a/lms/djangoapps/instructor/tests/test_enrollment.py +++ b/lms/djangoapps/instructor/tests/test_enrollment.py @@ -18,7 +18,7 @@ from submissions import api as sub_api from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.capa.tests.response_xml_factory import MultipleChoiceResponseXMLFactory from common.djangoapps.student.models import CourseEnrollment, CourseEnrollmentAllowed, anonymous_id_for_user from common.djangoapps.student.roles import CourseCcxCoachRole @@ -380,22 +380,22 @@ def setUpClass(cls): ) cls.course_key = cls.course.location.course_key # lint-amnesty, pylint: disable=no-member with cls.store.bulk_operations(cls.course.id, emit_signals=False): # lint-amnesty, pylint: disable=no-member - cls.parent = ItemFactory( + cls.parent = BlockFactory( category="library_content", parent=cls.course, publish_item=True, ) - cls.child = ItemFactory( + cls.child = BlockFactory( category="html", parent=cls.parent, publish_item=True, ) - cls.unrelated = ItemFactory( + cls.unrelated = BlockFactory( category="html", parent=cls.course, publish_item=True, ) - cls.team_enabled_ora = ItemFactory.create( + cls.team_enabled_ora = BlockFactory.create( parent=cls.parent, category="openassessment", teams_enabled=True, @@ -712,18 +712,18 @@ class TestStudentModuleGrading(SharedModuleStoreTestCase): def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, category="chapter", display_name="Test Chapter" ) - cls.sequence = ItemFactory.create( + cls.sequence = BlockFactory.create( parent=cls.chapter, category='sequential', display_name="Test Sequential 1", graded=True ) - cls.vertical = ItemFactory.create( + cls.vertical = BlockFactory.create( parent=cls.sequence, category='vertical', display_name='Test Vertical 1' @@ -733,7 +733,7 @@ def setUpClass(cls): choices=[False, False, True, False], choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3'] ) - cls.problem = ItemFactory.create( + cls.problem = BlockFactory.create( parent=cls.vertical, category="problem", display_name="Test Problem", diff --git a/lms/djangoapps/instructor/tests/test_services.py b/lms/djangoapps/instructor/tests/test_services.py index 3e7f472529be..e16df1678f6e 100644 --- a/lms/djangoapps/instructor/tests/test_services.py +++ b/lms/djangoapps/instructor/tests/test_services.py @@ -16,7 +16,7 @@ from lms.djangoapps.instructor.access import allow_access from lms.djangoapps.instructor.services import InstructorService from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # 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 Group, UserPartition # lint-amnesty, pylint: disable=wrong-import-order @@ -30,12 +30,12 @@ def setUpClass(cls): super().setUpClass() cls.email = 'escalation@test.com' cls.course = CourseFactory.create(proctoring_escalation_email=cls.email) - cls.section = ItemFactory.create(parent=cls.course, category='chapter') - cls.subsection = ItemFactory.create(parent=cls.section, category='sequential') - cls.unit = ItemFactory.create(parent=cls.subsection, category='vertical') - cls.problem = ItemFactory.create(parent=cls.unit, category='problem') - cls.unit_2 = ItemFactory.create(parent=cls.subsection, category='vertical') - cls.problem_2 = ItemFactory.create(parent=cls.unit_2, category='problem') + cls.section = BlockFactory.create(parent=cls.course, category='chapter') + cls.subsection = BlockFactory.create(parent=cls.section, category='sequential') + cls.unit = BlockFactory.create(parent=cls.subsection, category='vertical') + cls.problem = BlockFactory.create(parent=cls.unit, category='problem') + cls.unit_2 = BlockFactory.create(parent=cls.subsection, category='vertical') + cls.problem_2 = BlockFactory.create(parent=cls.unit_2, category='problem') cls.complete_error_prefix = ('Error occurred while attempting to complete student attempt for ' 'user {user} for content_id {content_id}. ') @@ -128,16 +128,16 @@ def test_complete_student_attempt_success(self, mock_submit): """ # Section, subsection, and unit are all aggregators and not completable so should # not be submitted. - section = ItemFactory.create(parent=self.course, category='chapter') - subsection = ItemFactory.create(parent=section, category='sequential') - unit = ItemFactory.create(parent=subsection, category='vertical') + section = BlockFactory.create(parent=self.course, category='chapter') + subsection = BlockFactory.create(parent=section, category='sequential') + unit = BlockFactory.create(parent=subsection, category='vertical') # should both be submitted - video = ItemFactory.create(parent=unit, category='video') - problem = ItemFactory.create(parent=unit, category='problem') + video = BlockFactory.create(parent=unit, category='video') + problem = BlockFactory.create(parent=unit, category='problem') # Not a completable block - ItemFactory.create(parent=unit, category='discussion') + BlockFactory.create(parent=unit, category='discussion') with override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, True): self.service.complete_student_attempt(self.student.username, str(subsection.location)) @@ -167,25 +167,25 @@ def test_complete_student_attempt_split_test(self, mock_submit): ] ) course = CourseFactory.create(user_partitions=[partition]) - section = ItemFactory.create(parent=course, category='chapter') - subsection = ItemFactory.create(parent=section, category='sequential') + section = BlockFactory.create(parent=course, category='chapter') + subsection = BlockFactory.create(parent=section, category='sequential') c0_url = course.id.make_usage_key('vertical', 'split_test_cond0') c1_url = course.id.make_usage_key('vertical', 'split_test_cond1') - split_test = ItemFactory.create( + split_test = BlockFactory.create( parent=subsection, category='split_test', user_partition_id=0, group_id_to_child={'0': c0_url, '1': c1_url}, ) - cond0vert = ItemFactory.create(parent=split_test, category='vertical', location=c0_url) - ItemFactory.create(parent=cond0vert, category='video') - ItemFactory.create(parent=cond0vert, category='problem') + cond0vert = BlockFactory.create(parent=split_test, category='vertical', location=c0_url) + BlockFactory.create(parent=cond0vert, category='video') + BlockFactory.create(parent=cond0vert, category='problem') - cond1vert = ItemFactory.create(parent=split_test, category='vertical', location=c1_url) - ItemFactory.create(parent=cond1vert, category='video') - ItemFactory.create(parent=cond1vert, category='html') + cond1vert = BlockFactory.create(parent=split_test, category='vertical', location=c1_url) + BlockFactory.create(parent=cond1vert, category='video') + BlockFactory.create(parent=cond1vert, category='html') with override_waffle_switch(ENABLE_COMPLETION_TRACKING_SWITCH, True): self.service.complete_student_attempt(self.student.username, str(subsection.location)) diff --git a/lms/djangoapps/instructor/tests/test_spoc_gradebook.py b/lms/djangoapps/instructor/tests/test_spoc_gradebook.py index 1f23ba680794..bf574e8f506f 100644 --- a/lms/djangoapps/instructor/tests/test_spoc_gradebook.py +++ b/lms/djangoapps/instructor/tests/test_spoc_gradebook.py @@ -8,7 +8,7 @@ from lms.djangoapps.courseware.tests.factories import StudentModuleFactory from lms.djangoapps.grades.api import task_compute_all_grades_for_course from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order USER_COUNT = 11 @@ -33,17 +33,17 @@ def setUpClass(cls): # Now give it some content with cls.store.bulk_operations(cls.course.id, emit_signals=False): - chapter = ItemFactory.create( + chapter = BlockFactory.create( parent_location=cls.course.location, category="sequential", ) - section = ItemFactory.create( + section = BlockFactory.create( parent_location=chapter.location, category="sequential", metadata={'graded': True, 'format': 'Homework'} ) cls.items = [ - ItemFactory.create( + BlockFactory.create( parent_location=section.location, category="problem", data=StringResponseXMLFactory().build_xml(answer='foo'), diff --git a/lms/djangoapps/instructor/tests/test_tools.py b/lms/djangoapps/instructor/tests/test_tools.py index fb12758ffc35..f853c2c05fc3 100644 --- a/lms/djangoapps/instructor/tests/test_tools.py +++ b/lms/djangoapps/instructor/tests/test_tools.py @@ -21,7 +21,7 @@ from xmodule.modulestore.tests.django_utils import ( TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase, SharedModuleStoreTestCase, ) -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from openedx.core.djangoapps.course_date_signals import handlers @@ -109,8 +109,8 @@ def setUpClass(cls): super().setUpClass() course = CourseFactory.create() with cls.store.bulk_operations(course.id, emit_signals=False): - cls.week1 = ItemFactory.create(parent=course) - cls.homework = ItemFactory.create(parent=cls.week1) + cls.week1 = BlockFactory.create(parent=course) + cls.homework = BlockFactory.create(parent=cls.week1) # get updated course cls.course = cls.store.get_item(course.location) @@ -145,9 +145,9 @@ def setUp(self): super().setUp() course = CourseFactory.create() - week1 = ItemFactory.create(parent=course) - week2 = ItemFactory.create(parent=course) - child = ItemFactory.create(parent=week1) + week1 = BlockFactory.create(parent=course) + week2 = BlockFactory.create(parent=course) + child = BlockFactory.create(parent=week1) due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=UTC) set_dates_for_course(course.id, [ @@ -214,11 +214,11 @@ def setUp(self): self.due = due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=UTC) course = CourseFactory.create() - week1 = ItemFactory.create(due=due, parent=course) - week2 = ItemFactory.create(due=due, parent=course) - week3 = ItemFactory.create(parent=course) - homework = ItemFactory.create(parent=week1) - assignment = ItemFactory.create(parent=homework, due=due) + week1 = BlockFactory.create(due=due, parent=course) + week2 = BlockFactory.create(due=due, parent=course) + week3 = BlockFactory.create(parent=course) + homework = BlockFactory.create(parent=week1) + assignment = BlockFactory.create(parent=homework, due=due) handlers.extract_dates(None, course.id) user = UserFactory.create() @@ -330,10 +330,10 @@ def setUp(self): due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=UTC) course = CourseFactory.create() - week1 = ItemFactory.create(due=due, parent=course) - week2 = ItemFactory.create(due=due, parent=course) + week1 = BlockFactory.create(due=due, parent=course) + week2 = BlockFactory.create(due=due, parent=course) - homework = ItemFactory.create( + homework = BlockFactory.create( parent=week1, due=due ) diff --git a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py index da495802e6a0..bca16977a98c 100644 --- a/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py +++ b/lms/djangoapps/instructor/tests/views/test_instructor_dashboard.py @@ -16,7 +16,7 @@ from pytz import UTC from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.edxmako.shortcuts import render_to_response @@ -557,7 +557,7 @@ def test_open_response_assessment_page(self): response = self.client.get(self.url) self.assertNotContains(response, ora_section) - ItemFactory.create(parent_location=self.course.location, category="openassessment") + BlockFactory.create(parent_location=self.course.location, category="openassessment") response = self.client.get(self.url) self.assertContains(response, ora_section) @@ -567,7 +567,7 @@ def test_open_response_assessment_page_orphan(self): orphaned openassessment block """ # create non-orphaned openassessment block - ItemFactory.create( + BlockFactory.create( parent_location=self.course.location, category="openassessment", ) @@ -627,7 +627,7 @@ def test_spoc_gradebook_mongo_calls(self): Test that the MongoDB cache is used in API to return grades """ # prepare course structure - course = ItemFactory.create( + course = BlockFactory.create( parent_location=self.course.location, category="course", display_name="Test course", @@ -640,14 +640,14 @@ def test_spoc_gradebook_mongo_calls(self): CourseEnrollmentFactory.create(user=student, course_id=self.course.id) students.append(student) - chapter = ItemFactory.create( + chapter = BlockFactory.create( parent=course, category='chapter', display_name="Chapter", publish_item=True, start=datetime.datetime(2015, 3, 1, tzinfo=UTC), ) - sequential = ItemFactory.create( + sequential = BlockFactory.create( parent=chapter, category='sequential', display_name="Lesson", @@ -655,7 +655,7 @@ def test_spoc_gradebook_mongo_calls(self): start=datetime.datetime(2015, 3, 1, tzinfo=UTC), metadata={'graded': True, 'format': 'Homework'}, ) - vertical = ItemFactory.create( + vertical = BlockFactory.create( parent=sequential, category='vertical', display_name='Subsection', @@ -663,7 +663,7 @@ def test_spoc_gradebook_mongo_calls(self): start=datetime.datetime(2015, 4, 1, tzinfo=UTC), ) for i in range(10): - problem = ItemFactory.create( + problem = BlockFactory.create( category="problem", parent=vertical, display_name="A Problem Block %d" % i, diff --git a/lms/djangoapps/instructor_task/tests/test_base.py b/lms/djangoapps/instructor_task/tests/test_base.py index 69d4e4a9c2df..2f1fcfdc5eb8 100644 --- a/lms/djangoapps/instructor_task/tests/test_base.py +++ b/lms/djangoapps/instructor_task/tests/test_base.py @@ -22,7 +22,7 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.capa.tests.response_xml_factory import OptionResponseXMLFactory from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from lms.djangoapps.courseware.model_data import StudentModule @@ -138,13 +138,13 @@ def add_course_content(self): Add a chapter and a sequential to the current course. """ # Add a chapter to the course - self.chapter = ItemFactory.create( + self.chapter = BlockFactory.create( parent_location=self.course.location, display_name=TEST_CHAPTER_NAME, ) # add a sequence to the course to which the problems can be added - self.problem_section = ItemFactory.create( + self.problem_section = BlockFactory.create( parent_location=self.chapter.location, category='sequential', metadata={'graded': True, 'format': 'Homework'}, @@ -235,12 +235,12 @@ def define_option_problem(self, problem_url_name, parent=None, **kwargs): factory = OptionResponseXMLFactory() factory_args = self._option_problem_factory_args() problem_xml = factory.build_xml(**factory_args) - return ItemFactory.create(parent_location=parent.location, - parent=parent, - category="problem", - display_name=problem_url_name, - data=problem_xml, - **kwargs) + return BlockFactory.create(parent_location=parent.location, + parent=parent, + category="problem", + display_name=problem_url_name, + data=problem_xml, + **kwargs) def redefine_option_problem(self, problem_url_name, correct_answer=OPTION_1, num_inputs=1, num_responses=2): """Change the problem definition so the answer is Option 2""" diff --git a/lms/djangoapps/instructor_task/tests/test_integration.py b/lms/djangoapps/instructor_task/tests/test_integration.py index db8413046a5e..f3f6a9c7c969 100644 --- a/lms/djangoapps/instructor_task/tests/test_integration.py +++ b/lms/djangoapps/instructor_task/tests/test_integration.py @@ -42,7 +42,7 @@ from openedx.core.djangoapps.util.testing import TestConditionalContent from openedx.core.lib.url_utils import quote_slashes from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import BlockFactory # lint-amnesty, pylint: disable=wrong-import-order log = logging.getLogger(__name__) @@ -322,10 +322,10 @@ def define_code_response_problem(self, problem_url_name): answer_display="answer", grader_payload=grader_payload, num_responses=2) - ItemFactory.create(parent_location=self.problem_section.location, - category="problem", - display_name=str(problem_url_name), - data=problem_xml) + BlockFactory.create(parent_location=self.problem_section.location, + category="problem", + display_name=str(problem_url_name), + data=problem_xml) def test_rescoring_code_problem(self): """Run rescore scenario on problem with code submission""" @@ -378,11 +378,11 @@ def check_func(expect, answer_given): # correct answer, and call a second time with that answer to confirm it's graded as correct. # Per-student rerandomization will at least generate different seeds for different users, so # we get a little more test coverage. - ItemFactory.create(parent_location=self.problem_section.location, - category="problem", - display_name=str(problem_url_name), - data=problem_xml, - metadata={"rerandomize": "per_student"}) + BlockFactory.create(parent_location=self.problem_section.location, + category="problem", + display_name=str(problem_url_name), + data=problem_xml, + metadata={"rerandomize": "per_student"}) def test_rescoring_randomized_problem(self): """Run rescore scenario on custom problem that uses randomize""" diff --git a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py index 52679fe16589..a148dad248c8 100644 --- a/lms/djangoapps/instructor_task/tests/test_tasks_helper.py +++ b/lms/djangoapps/instructor_task/tests/test_tasks_helper.py @@ -68,7 +68,7 @@ from openedx.core.djangoapps.util.testing import ContentGroupTestCase, TestConditionalContent from openedx.core.lib.teams_config import TeamsConfig from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order from xmodule.partitions.partitions import Group, UserPartition # lint-amnesty, pylint: disable=wrong-import-order from ..models import ReportStore @@ -689,7 +689,7 @@ def test_build_student_data_with_filter(self, filters, filtered_count): """ for idx in range(1, 6): self.define_option_problem(f'Problem{idx}') - item = ItemFactory.create( + item = BlockFactory.create( parent_location=self.problem_section.location, parent=self.problem_section, display_name=f"Item{idx}", @@ -828,7 +828,7 @@ def test_no_problems(self, use_tempfile, _): @patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task') @ddt.data(True, False) def test_single_problem(self, use_tempfile, _): - vertical = ItemFactory.create( + vertical = BlockFactory.create( parent_location=self.problem_section.location, category='vertical', metadata={'graded': True}, @@ -873,7 +873,7 @@ def test_single_problem_verified_student_only(self, use_tempfile, _): return_value=True, ): student_verified = self.create_student('user_verified', mode='verified') - vertical = ItemFactory.create( + vertical = BlockFactory.create( parent_location=self.problem_section.location, category='vertical', metadata={'graded': True}, @@ -896,7 +896,7 @@ def test_inactive_enrollment_included(self, use_tempfile, _): Students with inactive enrollments in a course should be included in Problem Grade Report. """ inactive_student = self.create_student('inactive-student', 'inactive@example.com', enrollment_active=False) - vertical = ItemFactory.create( + vertical = BlockFactory.create( parent_location=self.problem_section.location, category='vertical', metadata={'graded': True}, @@ -1045,18 +1045,18 @@ def test_problem_grade_report_valid_columns_order(self): problem_section_format = 'Homework %d' % i problem_vertical_name = 'Problem Unit %d' % i - chapter = ItemFactory.create(parent_location=self.course.location, - display_name=chapter_name) + chapter = BlockFactory.create(parent_location=self.course.location, + display_name=chapter_name) # Add a sequence to the course to which the problems can be added - problem_section = ItemFactory.create(parent_location=chapter.location, - category='sequential', - metadata={'graded': True, - 'format': problem_section_format}, - display_name=problem_section_name) + problem_section = BlockFactory.create(parent_location=chapter.location, + category='sequential', + metadata={'graded': True, + 'format': problem_section_format}, + display_name=problem_section_name) # Create a vertical - problem_vertical = ItemFactory.create( + problem_vertical = BlockFactory.create( parent_location=problem_section.location, category='vertical', display_name=problem_vertical_name @@ -1088,7 +1088,7 @@ def setUp(self): super().setUp() # construct cohorted problems to work on. self.add_course_content() - vertical = ItemFactory.create( + vertical = BlockFactory.create( parent_location=self.problem_section.location, category='vertical', metadata={'graded': True}, @@ -1757,16 +1757,16 @@ def create_course(self): }, metadata={"start": in_the_past} ) - self.chapter = ItemFactory.create(parent=self.course, category='chapter') + self.chapter = BlockFactory.create(parent=self.course, category='chapter') - self.problem_section = ItemFactory.create( + self.problem_section = BlockFactory.create( parent=self.chapter, category='sequential', metadata={'graded': True, 'format': 'Homework'}, display_name='Subsection' ) self.define_option_problem('Problem1', parent=self.problem_section) - self.hidden_section = ItemFactory.create( + self.hidden_section = BlockFactory.create( parent=self.chapter, category='sequential', metadata={'graded': True, 'format': 'Homework'}, @@ -1774,20 +1774,20 @@ def create_course(self): display_name='Hidden', ) self.define_option_problem('Problem2', parent=self.hidden_section) - self.unattempted_section = ItemFactory.create( + self.unattempted_section = BlockFactory.create( parent=self.chapter, category='sequential', metadata={'graded': True, 'format': 'Homework'}, display_name='Unattempted', ) self.define_option_problem('Problem3', parent=self.unattempted_section) - self.empty_section = ItemFactory.create( + self.empty_section = BlockFactory.create( parent=self.chapter, category='sequential', metadata={'graded': True, 'format': 'Homework'}, display_name='Empty', ) - self.unreleased_section = ItemFactory.create( + self.unreleased_section = BlockFactory.create( parent=self.chapter, category='sequential', metadata={'graded': True, 'format': 'Homework', 'start': in_the_future}, @@ -1893,7 +1893,7 @@ def test_course_grade_with_verified_student_only(self, _get_current_task): ): student_1 = self.create_student('user_honor') student_verified = self.create_student('user_verified', mode='verified') - vertical = ItemFactory.create( + vertical = BlockFactory.create( parent_location=self.problem_section.location, category='vertical', metadata={'graded': True}, @@ -1958,7 +1958,7 @@ def create_problem(self, problem_display_name='test_problem', parent=None): factory = MultipleChoiceResponseXMLFactory() args = {'choices': [False, True, False]} problem_xml = factory.build_xml(**args) - ItemFactory.create( + BlockFactory.create( parent_location=parent.location, parent=parent, category="problem", diff --git a/lms/djangoapps/lti_provider/tests/test_outcomes.py b/lms/djangoapps/lti_provider/tests/test_outcomes.py index 76228a1cce62..630d2b37ebd9 100644 --- a/lms/djangoapps/lti_provider/tests/test_outcomes.py +++ b/lms/djangoapps/lti_provider/tests/test_outcomes.py @@ -9,7 +9,7 @@ from lxml import etree from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator from xmodule.modulestore.tests.django_utils import TEST_DATA_MONGO_AMNESTY_MODULESTORE, ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls import lms.djangoapps.lti_provider.outcomes as outcomes from common.djangoapps.student.tests.factories import UserFactory @@ -306,9 +306,9 @@ def setUp(self): self.outcome_service = self.create_outcome_service('outcomes') self.course = CourseFactory.create() with self.store.bulk_operations(self.course.id, emit_signals=False): - self.chapter = ItemFactory.create(parent=self.course, category="chapter") - self.vertical = ItemFactory.create(parent=self.chapter, category="vertical") - self.unit = ItemFactory.create(parent=self.vertical, category="unit") + self.chapter = BlockFactory.create(parent=self.course, category="chapter") + self.vertical = BlockFactory.create(parent=self.chapter, category="vertical") + self.unit = BlockFactory.create(parent=self.vertical, category="unit") def create_outcome_service(self, id_suffix): """ diff --git a/lms/djangoapps/mobile_api/tests/test_milestones.py b/lms/djangoapps/mobile_api/tests/test_milestones.py index 5176c05b7afa..12de519b04c4 100644 --- a/lms/djangoapps/mobile_api/tests/test_milestones.py +++ b/lms/djangoapps/mobile_api/tests/test_milestones.py @@ -12,7 +12,7 @@ from lms.djangoapps.courseware.access_response import MilestoneAccessError from lms.djangoapps.courseware.tests.test_entrance_exam import add_entrance_exam_milestone, answer_entrance_exam_problem from openedx.core.djangolib.testing.utils import get_mock_request -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order class MobileAPIMilestonesMixin: @@ -89,21 +89,21 @@ def _add_entrance_exam(self): with self.store.bulk_operations(self.course.id): self.course.entrance_exam_enabled = True - self.entrance_exam = ItemFactory.create( + self.entrance_exam = BlockFactory.create( parent=self.course, category="chapter", display_name="Entrance Exam Chapter", is_entrance_exam=True, in_entrance_exam=True, ) - self.subsection_1 = ItemFactory.create( + self.subsection_1 = BlockFactory.create( parent=self.entrance_exam, category='sequential', display_name="The Only Exam Sequential", graded=True, in_entrance_exam=True, ) - self.problem_1 = ItemFactory.create( + self.problem_1 = BlockFactory.create( parent=self.subsection_1, category='problem', display_name="The Only Exam Problem", diff --git a/lms/djangoapps/mobile_api/users/tests.py b/lms/djangoapps/mobile_api/users/tests.py index 8eb6924bc0d7..f5ce65af6733 100644 --- a/lms/djangoapps/mobile_api/users/tests.py +++ b/lms/djangoapps/mobile_api/users/tests.py @@ -39,7 +39,7 @@ from openedx.features.course_duration_limits.models import CourseDurationLimitConfig from openedx.features.course_experience.tests.views.helpers import add_course_mode from xmodule.course_block import DEFAULT_START_DATE # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order from .. import errors from .serializers import CourseEnrollmentSerializer, CourseEnrollmentSerializerv05 @@ -457,23 +457,23 @@ def setUp(self): """ super().setUp() - self.section = ItemFactory.create( + self.section = BlockFactory.create( parent=self.course, category='chapter', ) - self.sub_section = ItemFactory.create( + self.sub_section = BlockFactory.create( parent=self.section, category='sequential', ) - self.unit = ItemFactory.create( + self.unit = BlockFactory.create( parent=self.sub_section, category='vertical', ) - self.other_sub_section = ItemFactory.create( + self.other_sub_section = BlockFactory.create( parent=self.section, category='sequential', ) - self.other_unit = ItemFactory.create( + self.other_unit = BlockFactory.create( parent=self.other_sub_section, category='vertical', ) diff --git a/lms/djangoapps/ora_staff_grader/tests/test_views.py b/lms/djangoapps/ora_staff_grader/tests/test_views.py index aacceda19a54..2f27a8059077 100644 --- a/lms/djangoapps/ora_staff_grader/tests/test_views.py +++ b/lms/djangoapps/ora_staff_grader/tests/test_views.py @@ -14,7 +14,7 @@ SharedModuleStoreTestCase, ) from xmodule.modulestore.tests.factories import CourseFactory -from xmodule.modulestore.tests.factories import ItemFactory +from xmodule.modulestore.tests.factories import BlockFactory from common.djangoapps.student.tests.factories import StaffFactory from lms.djangoapps.ora_staff_grader.constants import ( @@ -51,7 +51,7 @@ def setUpClass(cls): cls.course = CourseFactory.create() cls.course_key = cls.course.location.course_key - cls.ora_block = ItemFactory.create( + cls.ora_block = BlockFactory.create( category="openassessment", parent_location=cls.course.location, display_name="test", diff --git a/lms/djangoapps/program_enrollments/rest_api/v1/tests/test_views.py b/lms/djangoapps/program_enrollments/rest_api/v1/tests/test_views.py index f209d7c87c15..174d3ad198ff 100644 --- a/lms/djangoapps/program_enrollments/rest_api/v1/tests/test_views.py +++ b/lms/djangoapps/program_enrollments/rest_api/v1/tests/test_views.py @@ -22,7 +22,7 @@ from social_django.models import UserSocialAuth from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory as ModulestoreCourseFactory -from xmodule.modulestore.tests.factories import ItemFactory +from xmodule.modulestore.tests.factories import BlockFactory from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.student.models import CourseEnrollment @@ -1891,7 +1891,7 @@ def test_no_due_dates(self): ) @ddt.unpack def test_due_dates(self, now_time, course_in_progress): - section_1 = ItemFactory.create( + section_1 = BlockFactory.create( category='chapter', start=self.yesterday, due=self.tomorrow, @@ -1899,27 +1899,27 @@ def test_due_dates(self, now_time, course_in_progress): display_name='section 1' ) - subsection_1 = ItemFactory.create( + subsection_1 = BlockFactory.create( category='sequential', due=self.tomorrow, parent=section_1, display_name='subsection 1' ) - subsection_2 = ItemFactory.create( + subsection_2 = BlockFactory.create( category='sequential', due=self.tomorrow - timedelta(1), parent=section_1, display_name='subsection 2' ) - subsection_3 = ItemFactory.create( + subsection_3 = BlockFactory.create( category='sequential', parent=section_1, display_name='subsection 3' ) - unit_1 = ItemFactory.create( + unit_1 = BlockFactory.create( category='vertical', due=self.tomorrow + timedelta(2), parent=subsection_3, diff --git a/lms/djangoapps/teams/tests/test_views.py b/lms/djangoapps/teams/tests/test_views.py index 57b05622c70f..ead5da014fbe 100644 --- a/lms/djangoapps/teams/tests/test_views.py +++ b/lms/djangoapps/teams/tests/test_views.py @@ -32,7 +32,7 @@ from openedx.core.djangoapps.django_comment_common.utils import seed_permissions_roles from openedx.core.lib.teams_config import TeamsConfig from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order from .factories import CourseTeamFactory, LAST_ACTIVITY_AT from ..models import CourseTeamMembership from ..search_indexes import CourseTeam, CourseTeamIndexer, course_team_post_save_callback @@ -1687,30 +1687,30 @@ def setUpClass(cls): teamset_id = cls.solar_team.topic_id other_teamset_id = cls.wind_team.topic_id - section = ItemFactory.create( + section = BlockFactory.create( parent=course, category='chapter', display_name='Test Section' ) - subsection = ItemFactory.create( + subsection = BlockFactory.create( parent=section, category="sequential" ) - unit_1 = ItemFactory.create( + unit_1 = BlockFactory.create( parent=subsection, category="vertical" ) - open_assessment = ItemFactory.create( + open_assessment = BlockFactory.create( parent=unit_1, category="openassessment", teams_enabled=True, selected_teamset_id=teamset_id ) - unit_2 = ItemFactory.create( + unit_2 = BlockFactory.create( parent=subsection, category="vertical" ) - off_team_open_assessment = ItemFactory.create( # pylint: disable=unused-variable + off_team_open_assessment = BlockFactory.create( # pylint: disable=unused-variable parent=unit_2, category="openassessment", teams_enabled=True, diff --git a/lms/lib/courseware_search/test/test_lms_filter_generator.py b/lms/lib/courseware_search/test/test_lms_filter_generator.py index 632f6c55e2a0..492cf64d8c30 100644 --- a/lms/lib/courseware_search/test/test_lms_filter_generator.py +++ b/lms/lib/courseware_search/test/test_lms_filter_generator.py @@ -7,7 +7,7 @@ from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order class LmsSearchFilterGeneratorTestCase(ModuleStoreTestCase): @@ -34,14 +34,14 @@ def build_courses(self): ) ] - self.chapter = ItemFactory.create( + self.chapter = BlockFactory.create( parent_location=self.courses[0].location, category='chapter', display_name="Week 1", publish_item=True, ) - self.chapter2 = ItemFactory.create( + self.chapter2 = BlockFactory.create( parent_location=self.courses[1].location, category='chapter', display_name="Week 1", diff --git a/lms/lib/courseware_search/test/test_lms_result_processor.py b/lms/lib/courseware_search/test/test_lms_result_processor.py index d7f3484d424e..c482ce2ca810 100644 --- a/lms/lib/courseware_search/test/test_lms_result_processor.py +++ b/lms/lib/courseware_search/test/test_lms_result_processor.py @@ -6,7 +6,7 @@ from common.djangoapps.student.tests.factories import UserFactory from lms.lib.courseware_search.lms_result_processor import LmsSearchResultProcessor from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order class LmsSearchResultProcessorTestCase(ModuleStoreTestCase): @@ -24,37 +24,37 @@ def build_course(self): run='test_run', display_name='Elasticsearch test course', ) - self.section = ItemFactory.create( + self.section = BlockFactory.create( parent=self.course, category='chapter', display_name='Test Section', ) - self.subsection = ItemFactory.create( + self.subsection = BlockFactory.create( parent=self.section, category='sequential', display_name='Test Subsection', ) - self.vertical = ItemFactory.create( + self.vertical = BlockFactory.create( parent=self.subsection, category='vertical', display_name='Test Unit', ) - self.html = ItemFactory.create( + self.html = BlockFactory.create( parent=self.vertical, category='html', display_name='Test Html control', ) - self.ghost_subsection = ItemFactory.create( + self.ghost_subsection = BlockFactory.create( parent=self.section, category='sequential', display_name=None, ) - self.ghost_vertical = ItemFactory.create( + self.ghost_vertical = BlockFactory.create( parent=self.ghost_subsection, category='vertical', display_name=None, ) - self.ghost_html = ItemFactory.create( + self.ghost_html = BlockFactory.create( parent=self.ghost_vertical, category='html', display_name='Ghost Html control', diff --git a/lms/lib/tests/test_utils.py b/lms/lib/tests/test_utils.py index eb8e76e9c0cc..ae0aea31d7e3 100644 --- a/lms/lib/tests/test_utils.py +++ b/lms/lib/tests/test_utils.py @@ -5,7 +5,7 @@ from lms.lib import utils from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order class LmsUtilsTest(ModuleStoreTestCase): @@ -20,17 +20,17 @@ def setUp(self): super().setUp() self.course = CourseFactory.create() - self.chapter = ItemFactory.create(category="chapter", parent_location=self.course.location) - self.sequential = ItemFactory.create(category="sequential", parent_location=self.chapter.location) - self.vertical = ItemFactory.create(category="vertical", parent_location=self.sequential.location) - self.html_block_1 = ItemFactory.create(category="html", parent_location=self.vertical.location) - self.vertical_with_container = ItemFactory.create( + self.chapter = BlockFactory.create(category="chapter", parent_location=self.course.location) + self.sequential = BlockFactory.create(category="sequential", parent_location=self.chapter.location) + self.vertical = BlockFactory.create(category="vertical", parent_location=self.sequential.location) + self.html_block_1 = BlockFactory.create(category="html", parent_location=self.vertical.location) + self.vertical_with_container = BlockFactory.create( category="vertical", parent_location=self.sequential.location ) - self.child_container = ItemFactory.create( + self.child_container = BlockFactory.create( category="split_test", parent_location=self.vertical_with_container.location) - self.child_vertical = ItemFactory.create(category="vertical", parent_location=self.child_container.location) - self.child_html_block = ItemFactory.create(category="html", parent_location=self.child_vertical.location) + self.child_vertical = BlockFactory.create(category="vertical", parent_location=self.child_container.location) + self.child_html_block = BlockFactory.create(category="html", parent_location=self.child_vertical.location) # Read again so that children lists are accurate self.course = self.store.get_item(self.course.location) diff --git a/lms/lib/xblock/test/test_mixin.py b/lms/lib/xblock/test/test_mixin.py index 165167a36db0..248ac234ca6f 100644 --- a/lms/lib/xblock/test/test_mixin.py +++ b/lms/lib/xblock/test/test_mixin.py @@ -15,7 +15,7 @@ ) from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, ToyCourseFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, ToyCourseFactory # lint-amnesty, pylint: disable=wrong-import-order from xmodule.partitions.partitions import Group, UserPartition # lint-amnesty, pylint: disable=wrong-import-order @@ -41,13 +41,13 @@ def build_course(self): self.group1 = self.user_partition.groups[0] self.group2 = self.user_partition.groups[1] self.course = CourseFactory.create(user_partitions=[self.user_partition]) - section = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section') - subsection = ItemFactory.create(parent=section, category='sequential', display_name='Test Subsection') - vertical = ItemFactory.create(parent=subsection, category='vertical', display_name='Test Unit') - video = ItemFactory.create(parent=vertical, category='video', display_name='Test Video 1') - split_test = ItemFactory.create(parent=vertical, category='split_test', display_name='Test Content Experiment') - child_vertical = ItemFactory.create(parent=split_test, category='vertical') - child_html_block = ItemFactory.create(parent=child_vertical, category='html') + section = BlockFactory.create(parent=self.course, category='chapter', display_name='Test Section') + subsection = BlockFactory.create(parent=section, category='sequential', display_name='Test Subsection') + vertical = BlockFactory.create(parent=subsection, category='vertical', display_name='Test Unit') + video = BlockFactory.create(parent=vertical, category='video', display_name='Test Video 1') + split_test = BlockFactory.create(parent=vertical, category='split_test', display_name='Test Content Experiment') + child_vertical = BlockFactory.create(parent=split_test, category='vertical') + child_html_block = BlockFactory.create(parent=child_vertical, category='html') self.section_location = section.location self.subsection_location = subsection.location self.vertical_location = vertical.location @@ -282,8 +282,8 @@ class OpenAssessmentBlockMixinTestCase(ModuleStoreTestCase): def setUp(self): super().setUp() self.course = CourseFactory.create() - self.section = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section') - self.open_assessment = ItemFactory.create( + self.section = BlockFactory.create(parent=self.course, category='chapter', display_name='Test Section') + self.open_assessment = BlockFactory.create( parent=self.section, category="openassessment", display_name="untitled", @@ -333,7 +333,7 @@ def test_parents_draft_content(self): with self.store.default_store(ModuleStoreEnum.Type.split): self.build_course() subsection = self.store.get_item(self.subsection_location) - new_vertical = ItemFactory.create(parent=subsection, category='vertical', display_name='New Test Unit') + new_vertical = BlockFactory.create(parent=subsection, category='vertical', display_name='New Test Unit') child_to_move_location = self.video_location.for_branch(None) new_parent_location = new_vertical.location.for_branch(None) old_parent_location = self.vertical_location.for_branch(None) diff --git a/openedx/core/djangoapps/bookmarks/tests/test_models.py b/openedx/core/djangoapps/bookmarks/tests/test_models.py index 9aff8277e02f..2c6877218acc 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_models.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_models.py @@ -15,7 +15,7 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls from openedx.core.djangolib.testing.utils import skip_unless_lms from common.djangoapps.student.tests.factories import AdminFactory, UserFactory @@ -57,31 +57,31 @@ def setup_data(self, store_type=ModuleStoreEnum.Type.split): self.course = CourseFactory.create(display_name='An Introduction to API Testing') self.course_id = str(self.course.id) - self.chapter_1 = ItemFactory.create( + self.chapter_1 = BlockFactory.create( parent=self.course, category='chapter', display_name='Week 1' ) - self.chapter_2 = ItemFactory.create( + self.chapter_2 = BlockFactory.create( parent=self.course, category='chapter', display_name='Week 2' ) - self.sequential_1 = ItemFactory.create( + self.sequential_1 = BlockFactory.create( parent=self.chapter_1, category='sequential', display_name='Lesson 1' ) - self.sequential_2 = ItemFactory.create( + self.sequential_2 = BlockFactory.create( parent=self.chapter_1, category='sequential', display_name='Lesson 2' ) - self.vertical_1 = ItemFactory.create( + self.vertical_1 = BlockFactory.create( parent=self.sequential_1, category='vertical', display_name='Subsection 1' ) - self.vertical_2 = ItemFactory.create( + self.vertical_2 = BlockFactory.create( parent=self.sequential_2, category='vertical', display_name='Subsection 2' ) - self.vertical_3 = ItemFactory.create( + self.vertical_3 = BlockFactory.create( parent=self.sequential_2, category='vertical', display_name='Subsection 3' ) - self.html_1 = ItemFactory.create( + self.html_1 = BlockFactory.create( parent=self.vertical_2, category='html', display_name='Details 1' ) @@ -131,19 +131,19 @@ def setup_data(self, store_type=ModuleStoreEnum.Type.split): with self.store.bulk_operations(self.other_course.id): - self.other_chapter_1 = ItemFactory.create( + self.other_chapter_1 = BlockFactory.create( parent=self.other_course, category='chapter', display_name='Other Week 1' ) - self.other_sequential_1 = ItemFactory.create( + self.other_sequential_1 = BlockFactory.create( parent=self.other_chapter_1, category='sequential', display_name='Other Lesson 1' ) - self.other_sequential_2 = ItemFactory.create( + self.other_sequential_2 = BlockFactory.create( parent=self.other_chapter_1, category='sequential', display_name='Other Lesson 2' ) - self.other_vertical_1 = ItemFactory.create( + self.other_vertical_1 = BlockFactory.create( parent=self.other_sequential_1, category='vertical', display_name='Other Subsection 1' ) - self.other_vertical_2 = ItemFactory.create( + self.other_vertical_2 = BlockFactory.create( parent=self.other_sequential_1, category='vertical', display_name='Other Subsection 2' ) @@ -179,7 +179,7 @@ def create_course_with_blocks(self, children_per_block=1, depth=1, store_type=Mo for block in blocks_at_current_level: for __ in range(children_per_block): - blocks_at_next_level += [ItemFactory.create( + blocks_at_next_level += [BlockFactory.create( parent_location=block.location, display_name=str(display_name) )] display_name += 1 @@ -195,7 +195,7 @@ def create_course_with_bookmarks_count(self, count, store_type=ModuleStoreEnum.T course = CourseFactory.create() - blocks = [ItemFactory.create( + blocks = [BlockFactory.create( parent=course, category='chapter', display_name=str(index) ) for index in range(count)] @@ -251,7 +251,7 @@ class BookmarkModelTests(BookmarksTestsBase): def setUp(self): super().setUp() - self.vertical_4 = ItemFactory.create( + self.vertical_4 = BlockFactory.create( parent=self.sequential_2, category='vertical', display_name=None @@ -344,7 +344,7 @@ def test_path(self, seconds_delta, paths, get_path_call_count, mock_get_path): block_path = [PathItem(UsageKey.from_string(EXAMPLE_USAGE_KEY_1), '1')] mock_get_path.return_value = block_path - html = ItemFactory.create( + html = BlockFactory.create( parent=self.other_chapter_1, category='html', display_name='Other Lesson 1' ) diff --git a/openedx/core/djangoapps/bookmarks/tests/test_tasks.py b/openedx/core/djangoapps/bookmarks/tests/test_tasks.py index acddf69fc565..36172d904c5a 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_tasks.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_tasks.py @@ -6,7 +6,7 @@ import ddt from xmodule.modulestore import ModuleStoreEnum -from xmodule.modulestore.tests.factories import ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import BlockFactory, check_mongo_calls from ..models import XBlockCache from ..tasks import _calculate_course_xblocks_data, _update_xblocks_cache @@ -164,7 +164,7 @@ def test_update_xblocks_cache_with_display_name_none(self): """ Test that the xblocks data is persisted correctly with display_name=None. """ - block_with_display_name_none = ItemFactory.create( + block_with_display_name_none = BlockFactory.create( parent=self.sequential_2, category='vertical', display_name=None ) diff --git a/openedx/core/djangoapps/ccxcon/tests/test_api.py b/openedx/core/djangoapps/ccxcon/tests/test_api.py index e3047af0153c..762dba70e8e9 100644 --- a/openedx/core/djangoapps/ccxcon/tests/test_api.py +++ b/openedx/core/djangoapps/ccxcon/tests/test_api.py @@ -10,7 +10,7 @@ from opaque_keys.edx.keys import CourseKey from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from openedx.core.djangoapps.ccxcon import api as ccxconapi from common.djangoapps.student.tests.factories import AdminFactory @@ -51,16 +51,16 @@ def setUpClass(cls): ) cls.chapters = [ - ItemFactory.create(start=start, parent=course) for _ in range(2) + BlockFactory.create(start=start, parent=course) for _ in range(2) ] cls.sequentials = flatten([ [ - ItemFactory.create(parent=chapter) for _ in range(2) + BlockFactory.create(parent=chapter) for _ in range(2) ] for chapter in cls.chapters ]) cls.verticals = flatten([ [ - ItemFactory.create( + BlockFactory.create( start=start, due=due, parent=sequential, graded=True, format='Homework', category='vertical' ) for _ in range(2) ] for sequential in cls.sequentials @@ -71,7 +71,7 @@ def setUpClass(cls): with cls.store.bulk_operations(course.id, emit_signals=False): blocks = flatten([ # pylint: disable=unused-variable [ - ItemFactory.create(parent=vertical) for _ in range(2) + BlockFactory.create(parent=vertical) for _ in range(2) ] for vertical in cls.verticals ]) diff --git a/openedx/core/djangoapps/course_date_signals/tests.py b/openedx/core/djangoapps/course_date_signals/tests.py index 1b01d7429d51..ee1e95b7b5a2 100644 --- a/openedx/core/djangoapps/course_date_signals/tests.py +++ b/openedx/core/djangoapps/course_date_signals/tests.py @@ -4,7 +4,7 @@ from edx_toggles.toggles.testutils import override_waffle_flag from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from cms.djangoapps.contentstore.config.waffle import CUSTOM_RELATIVE_DATES from openedx.core.djangoapps.course_date_signals.handlers import ( @@ -25,7 +25,7 @@ def setUp(self): super().setUp() course = CourseFactory.create() for i in range(4): - ItemFactory(parent=course, category="sequential", display_name=f"Section {i}") + BlockFactory(parent=course, category="sequential", display_name=f"Section {i}") # get updated course self.course = self.store.get_item(course.location) @@ -43,7 +43,7 @@ def test_basic_spacing(self): def test_hidden_sections(self): for _ in range(2): - ItemFactory(parent=self.course, category="sequential", visible_to_staff_only=True) + BlockFactory(parent=self.course, category="sequential", visible_to_staff_only=True) expected_sections = [ (0, 'Section 0', timedelta(days=7)), (1, 'Section 1', timedelta(days=14)), @@ -61,14 +61,14 @@ def test_dates_for_ungraded_assignments(self): children leaf nodes include an assignment that is graded and scored """ with self.store.bulk_operations(self.course.id): - sequence = ItemFactory(parent=self.course, category="sequential") - vertical = ItemFactory(parent=sequence, category="vertical") + sequence = BlockFactory(parent=self.course, category="sequential") + vertical = BlockFactory(parent=sequence, category="vertical") sequence = self.store.get_item(sequence.location) assert _has_assignment_blocks(sequence) is False # Ungraded problems do not count as assignment blocks - ItemFactory.create( + BlockFactory.create( parent=vertical, category='problem', graded=True, @@ -77,7 +77,7 @@ def test_dates_for_ungraded_assignments(self): sequence = self.store.get_item(sequence.location) assert _has_assignment_blocks(sequence) is False - ItemFactory.create( + BlockFactory.create( parent=vertical, category='problem', graded=False, @@ -87,7 +87,7 @@ def test_dates_for_ungraded_assignments(self): assert _has_assignment_blocks(sequence) is False # Method will return true after adding a graded, scored assignment block - ItemFactory.create( + BlockFactory.create( parent=vertical, category='problem', graded=True, @@ -102,22 +102,22 @@ def test_sequence_with_graded_and_ungraded_assignments(self): even if the block has graded siblings in the sequence """ with self.store.bulk_operations(self.course.id): - sequence = ItemFactory(parent=self.course, category="sequential") - vertical = ItemFactory(parent=sequence, category="vertical") + sequence = BlockFactory(parent=self.course, category="sequential") + vertical = BlockFactory(parent=sequence, category="vertical") sequence = self.store.get_item(sequence.location) - ItemFactory.create( + BlockFactory.create( parent=vertical, category='problem', graded=False, weight=1, ) - ungraded_problem_2 = ItemFactory.create( + ungraded_problem_2 = BlockFactory.create( parent=vertical, category='problem', graded=True, weight=0, ) - graded_problem_1 = ItemFactory.create( + graded_problem_1 = BlockFactory.create( parent=vertical, category='problem', graded=True, @@ -135,20 +135,20 @@ def test_sequence_with_ora_and_non_ora_assignments(self): _gather_graded_items should not set a due date for ORA problems """ with self.store.bulk_operations(self.course.id): - sequence = ItemFactory(parent=self.course, category="sequential") - vertical = ItemFactory(parent=sequence, category="vertical") - ItemFactory.create( + sequence = BlockFactory(parent=self.course, category="sequential") + vertical = BlockFactory(parent=sequence, category="vertical") + BlockFactory.create( parent=vertical, category='openassessment', graded=True ) - ungraded_problem_2 = ItemFactory.create( + ungraded_problem_2 = BlockFactory.create( parent=vertical, category='problem', graded=True, weight=0, ) - graded_problem_1 = ItemFactory.create( + graded_problem_1 = BlockFactory.create( parent=vertical, category='problem', graded=True, @@ -168,10 +168,10 @@ def test_get_custom_pacing_children(self): """ # A subsection with multiple units but no problems. Units should inherit due date. with self.store.bulk_operations(self.course.id): - sequence = ItemFactory(parent=self.course, category='sequential', relative_weeks_due=2) - vertical1 = ItemFactory(parent=sequence, category='vertical') - vertical2 = ItemFactory(parent=sequence, category='vertical') - vertical3 = ItemFactory(parent=sequence, category='vertical') + sequence = BlockFactory(parent=self.course, category='sequential', relative_weeks_due=2) + vertical1 = BlockFactory(parent=sequence, category='vertical') + vertical2 = BlockFactory(parent=sequence, category='vertical') + vertical3 = BlockFactory(parent=sequence, category='vertical') expected_dates = [ (sequence.location, {'due': timedelta(weeks=2)}), (vertical1.location, {'due': timedelta(weeks=2)}), @@ -184,8 +184,8 @@ def test_get_custom_pacing_children(self): with self.store.bulk_operations(self.course.id): # A subsection with multiple units, each of which has a problem. # Problems should also inherit due date. - problem1 = ItemFactory(parent=vertical1, category='problem') - problem2 = ItemFactory(parent=vertical2, category='problem') + problem1 = BlockFactory(parent=vertical1, category='problem') + problem2 = BlockFactory(parent=vertical2, category='problem') expected_dates.extend([ (problem1.location, {'due': timedelta(weeks=2)}), (problem2.location, {'due': timedelta(weeks=2)}) @@ -194,13 +194,13 @@ def test_get_custom_pacing_children(self): self.assertCountEqual(_get_custom_pacing_children(sequence, 2), expected_dates) # A subsection that has ORA as a problem. ORA should not inherit due date. - ItemFactory.create(parent=vertical3, category='openassessment') + BlockFactory.create(parent=vertical3, category='openassessment') sequence = self.store.get_item(sequence.location) self.assertCountEqual(_get_custom_pacing_children(sequence, 2), expected_dates) # A subsection that has an ORA problem and a non ORA problem. ORA should # not inherit due date, but non ORA problems should. - problem3 = ItemFactory(parent=vertical3, category='problem') + problem3 = BlockFactory(parent=vertical3, category='problem') expected_dates.append((problem3.location, {'due': timedelta(weeks=2)})) sequence = self.store.get_item(sequence.location) self.assertCountEqual(_get_custom_pacing_children(sequence, 2), expected_dates) @@ -216,7 +216,7 @@ def setUp(self): super().setUp() SelfPacedRelativeDatesConfig.objects.create(enabled=True) course = CourseFactory.create(self_paced=True) - self.chapter = ItemFactory.create(category='chapter', parent=course) + self.chapter = BlockFactory.create(category='chapter', parent=course) # get updated course self.course = self.store.get_item(course.location) @@ -228,9 +228,9 @@ def test_extract_dates_from_course_inheritance(self): (ex. If a subsection is assigned a due date, its children should also have the same due date) """ with self.store.bulk_operations(self.course.id): - sequential = ItemFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=3) - vertical = ItemFactory.create(category='vertical', parent=sequential) - problem = ItemFactory.create(category='problem', parent=vertical) + sequential = BlockFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=3) + vertical = BlockFactory.create(category='vertical', parent=sequential) + problem = BlockFactory.create(category='problem', parent=vertical) expected_dates = [ (self.course.location, {}), (self.chapter.location, {'due': timedelta(days=21)}), @@ -251,9 +251,9 @@ def test_extract_dates_from_course_custom_and_default_pls_one_subsection(self): PLS logic of evenly spaced sections. """ with self.store.bulk_operations(self.course.id): - sequential = ItemFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=3) - ItemFactory.create(category='sequential', parent=self.chapter) - ItemFactory.create(category='sequential', parent=self.chapter) + sequential = BlockFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=3) + BlockFactory.create(category='sequential', parent=self.chapter) + BlockFactory.create(category='sequential', parent=self.chapter) expected_dates = [ (self.course.location, {}), (self.chapter.location, {'due': timedelta(days=28)}), @@ -272,14 +272,14 @@ def test_extract_dates_from_course_custom_and_default_pls_one_subsection_graded( PLS logic of evenly spaced sections. """ with self.store.bulk_operations(self.course.id): - sequential1 = ItemFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=2) - vertical1 = ItemFactory.create(category='vertical', parent=sequential1) - problem1 = ItemFactory.create(category='problem', parent=vertical1) + sequential1 = BlockFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=2) + vertical1 = BlockFactory.create(category='vertical', parent=sequential1) + problem1 = BlockFactory.create(category='problem', parent=vertical1) - chapter2 = ItemFactory.create(category='chapter', parent=self.course) - sequential2 = ItemFactory.create(category='sequential', parent=chapter2, graded=True) - vertical2 = ItemFactory.create(category='vertical', parent=sequential2) - problem2 = ItemFactory.create(category='problem', parent=vertical2) + chapter2 = BlockFactory.create(category='chapter', parent=self.course) + sequential2 = BlockFactory.create(category='sequential', parent=chapter2, graded=True) + vertical2 = BlockFactory.create(category='vertical', parent=sequential2) + problem2 = BlockFactory.create(category='problem', parent=vertical2) expected_dates = [ (self.course.location, {}), @@ -306,9 +306,9 @@ def test_extract_dates_from_course_custom_and_default_pls_multiple_subsections_g PLS logic of evenly spaced sections. """ with self.store.bulk_operations(self.course.id): - sequential1 = ItemFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=4) - vertical1 = ItemFactory.create(category='vertical', parent=sequential1) - problem1 = ItemFactory.create(category='problem', parent=vertical1) + sequential1 = BlockFactory.create(category='sequential', parent=self.chapter, relative_weeks_due=4) + vertical1 = BlockFactory.create(category='vertical', parent=sequential1) + problem1 = BlockFactory.create(category='problem', parent=vertical1) expected_dates = [ (self.course.location, {}), @@ -320,11 +320,11 @@ def test_extract_dates_from_course_custom_and_default_pls_multiple_subsections_g for i in range(3): course = self.store.get_item(self.course.location) - chapter = ItemFactory.create(category='chapter', parent=course) + chapter = BlockFactory.create(category='chapter', parent=course) with self.store.bulk_operations(self.course.id): - sequential = ItemFactory.create(category='sequential', parent=chapter, graded=True) - vertical = ItemFactory.create(category='vertical', parent=sequential) - problem = ItemFactory.create(category='problem', parent=vertical) + sequential = BlockFactory.create(category='sequential', parent=chapter, graded=True) + vertical = BlockFactory.create(category='vertical', parent=sequential) + problem = BlockFactory.create(category='problem', parent=vertical) num_days = i * 14 + 28 expected_dates.extend([ (chapter.location, {'due': timedelta(days=num_days)}), @@ -344,10 +344,10 @@ def test_extract_dates_from_course_all_subsections(self): have their corresponding due dates. """ with self.store.bulk_operations(self.course.id): - chapter = ItemFactory.create(category='chapter', parent=self.course) - sequential1 = ItemFactory.create(category='sequential', parent=chapter, relative_weeks_due=3) - sequential2 = ItemFactory.create(category='sequential', parent=chapter, relative_weeks_due=4) - sequential3 = ItemFactory.create(category='sequential', parent=chapter, relative_weeks_due=5) + chapter = BlockFactory.create(category='chapter', parent=self.course) + sequential1 = BlockFactory.create(category='sequential', parent=chapter, relative_weeks_due=3) + sequential2 = BlockFactory.create(category='sequential', parent=chapter, relative_weeks_due=4) + sequential3 = BlockFactory.create(category='sequential', parent=chapter, relative_weeks_due=5) expected_dates = [ (self.course.location, {}), (chapter.location, {'due': timedelta(days=35)}), @@ -366,7 +366,7 @@ def test_extract_dates_from_course_no_subsections(self): """ with self.store.bulk_operations(self.course.id): for _ in range(3): - ItemFactory.create(category='sequential', parent=self.chapter) + BlockFactory.create(category='sequential', parent=self.chapter) expected_dates = [(self.course.location, {})] course = self.store.get_item(self.course.location) self.assertCountEqual(extract_dates_from_course(course), expected_dates) diff --git a/openedx/core/djangoapps/courseware_api/tests/pacts/views.py b/openedx/core/djangoapps/courseware_api/tests/pacts/views.py index e3ea735a7054..11abeac9cc5c 100644 --- a/openedx/core/djangoapps/courseware_api/tests/pacts/views.py +++ b/openedx/core/djangoapps/courseware_api/tests/pacts/views.py @@ -9,7 +9,7 @@ from django.views.decorators.http import require_POST from opaque_keys.edx.keys import CourseKey, UsageKey from xmodule.modulestore.tests.django_utils import ModuleStoreIsolationMixin -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, ToyCourseFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, ToyCourseFactory from common.djangoapps.course_modes.models import CourseMode from common.djangoapps.course_modes.tests.factories import CourseModeFactory @@ -90,19 +90,19 @@ def setup_sequence_metadata(self, request): enrollment_start=datetime(2020, 1, 1, 1, 1, 1), enrollment_end=datetime(2028, 1, 1, 1, 1, 1), ) - section = ItemFactory.create( + section = BlockFactory.create( parent=demo_course, category="chapter", display_name="Example Week 1: Getting Started" ) - subsection = ItemFactory.create( + subsection = BlockFactory.create( location=UsageKey.from_string('block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions'), parent=section, category="sequential", display_name="Homework - Question Styles", metadata={'graded': True, 'format': 'Homework'} ) - ItemFactory.create( + BlockFactory.create( location=UsageKey.from_string( 'block-v1:edX+DemoX+Demo_Course+type@vertical+block@2152d4a4aadc4cb0af5256394a3d1fc7' ), diff --git a/openedx/core/djangoapps/courseware_api/tests/test_views.py b/openedx/core/djangoapps/courseware_api/tests/test_views.py index a48a5d886929..be11c2913da4 100644 --- a/openedx/core/djangoapps/courseware_api/tests/test_views.py +++ b/openedx/core/djangoapps/courseware_api/tests/test_views.py @@ -18,7 +18,7 @@ from xmodule.data import CertificatesDisplayBehaviors from xmodule.modulestore.django import modulestore from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import ItemFactory, ToyCourseFactory +from xmodule.modulestore.tests.factories import BlockFactory, ToyCourseFactory from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID from common.djangoapps.course_modes.models import CourseMode @@ -68,9 +68,9 @@ def setUpClass(cls): certificate_available_date=_NEXT_WEEK, certificates_display_behavior=CertificatesDisplayBehaviors.END_WITH_DATE ) - cls.chapter = ItemFactory(parent=cls.course, category='chapter') - cls.sequence = ItemFactory(parent=cls.chapter, category='sequential', display_name='sequence') - cls.unit = ItemFactory.create(parent=cls.sequence, category='vertical', display_name="Vertical") + cls.chapter = BlockFactory(parent=cls.course, category='chapter') + cls.sequence = BlockFactory(parent=cls.chapter, category='sequential', display_name='sequence') + cls.unit = BlockFactory.create(parent=cls.sequence, category='vertical', display_name="Vertical") cls.user = UserFactory( username='student', @@ -467,7 +467,7 @@ def test_unit_error(self): def test_hidden_after_due(self, is_past_due, masquerade_config, expected_hidden, expected_banner): """Validate the metadata when hide-after-due is set for a sequence""" due = datetime.now() + timedelta(days=-1 if is_past_due else 1) - sequence = ItemFactory( + sequence = BlockFactory( parent_location=self.chapter.location, # ^ It is very important that we use parent_location=self.chapter.location (and not parent=self.chapter), as # chapter is a class attribute and passing it by value will update its .children=[] which will then leak diff --git a/openedx/core/djangoapps/credit/tests/test_tasks.py b/openedx/core/djangoapps/credit/tests/test_tasks.py index c283f2f5e97c..7d520f22f3cb 100644 --- a/openedx/core/djangoapps/credit/tests/test_tasks.py +++ b/openedx/core/djangoapps/credit/tests/test_tasks.py @@ -13,7 +13,7 @@ from openedx.core.djangoapps.credit.models import CreditCourse from openedx.core.djangoapps.credit.signals import on_course_publish from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order class TestTaskExecution(ModuleStoreTestCase): @@ -35,9 +35,10 @@ def setUp(self): super().setUp() self.course = CourseFactory.create(start=datetime(2015, 3, 1)) - self.section = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section') - self.subsection = ItemFactory.create(parent=self.section, category='sequential', display_name='Test Subsection') - self.vertical = ItemFactory.create(parent=self.subsection, category='vertical', display_name='Test Unit') + self.section = BlockFactory.create(parent=self.course, category='chapter', display_name='Test Section') + self.subsection = BlockFactory.create( + parent=self.section, category='sequential', display_name='Test Subsection') + self.vertical = BlockFactory.create(parent=self.subsection, category='vertical', display_name='Test Unit') def test_task_adding_requirements_invalid_course(self): """ @@ -182,7 +183,7 @@ def test_credit_requirement_blocks_ordering(self): """ self.add_credit_course(self.course.id) - subsection = ItemFactory.create(parent=self.section, category='sequential', display_name='Dummy Subsection') + subsection = BlockFactory.create(parent=self.section, category='sequential', display_name='Dummy Subsection') create_exam( course_id=str(self.course.id), content_id=str(subsection.location), diff --git a/openedx/core/djangoapps/discussions/tests/test_tasks.py b/openedx/core/djangoapps/discussions/tests/test_tasks.py index 47020d659e8d..58514ca3c518 100644 --- a/openedx/core/djangoapps/discussions/tests/test_tasks.py +++ b/openedx/core/djangoapps/discussions/tests/test_tasks.py @@ -13,7 +13,7 @@ update_unit_discussion_state_from_discussion_blocks, ) from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory class DiscussionConfigUpdateMixin: @@ -69,46 +69,46 @@ def setUp(self): ) self.course_key = course_key = self.course.id with self.store.bulk_operations(course_key): - self.section = ItemFactory.create(parent=course, category="chapter", display_name="Section") - self.sequence = ItemFactory.create(parent=self.section, category="sequential", display_name="Sequence") - self.unit = ItemFactory.create(parent=self.sequence, category="vertical", display_name="Unit") - ItemFactory.create( + self.section = BlockFactory.create(parent=course, category="chapter", display_name="Section") + self.sequence = BlockFactory.create(parent=self.section, category="sequential", display_name="Sequence") + self.unit = BlockFactory.create(parent=self.sequence, category="vertical", display_name="Unit") + BlockFactory.create( parent=self.sequence, category="vertical", display_name="Discussable Unit", discussion_enabled=True, ) - ItemFactory.create( + BlockFactory.create( parent=self.sequence, category="vertical", display_name="Non-Discussable Unit", discussion_enabled=False, ) - ItemFactory.create(parent=self.unit, category="html", display_name="An HTML Block") - graded_sequence = ItemFactory.create( + BlockFactory.create(parent=self.unit, category="html", display_name="An HTML Block") + graded_sequence = BlockFactory.create( parent=self.section, category="sequential", display_name="Graded Sequence", graded=True, ) - graded_unit = ItemFactory.create( + graded_unit = BlockFactory.create( parent=graded_sequence, category="vertical", display_name="Graded Unit", ) - ItemFactory.create( + BlockFactory.create( parent=graded_sequence, category="vertical", display_name="Discussable Graded Unit", discussion_enabled=True, ) - ItemFactory.create( + BlockFactory.create( parent=graded_sequence, category="vertical", display_name="Non-Discussable Graded Unit", discussion_enabled=False, ) - ItemFactory.create( + BlockFactory.create( parent=graded_unit, category="html", display_name="Graded HTML Block", @@ -195,35 +195,35 @@ def setUp(self): self.course = course = CourseFactory.create() self.course_key = course_key = self.course.id with self.store.bulk_operations(course_key): - section = ItemFactory.create( + section = BlockFactory.create( parent=course, category="chapter", display_name="Section" ) - sequence = ItemFactory.create( + sequence = BlockFactory.create( parent=section, category="sequential", display_name="Sequence" ) - self.unit_discussible = unit_discussible = ItemFactory.create( + self.unit_discussible = unit_discussible = BlockFactory.create( parent=sequence, category="vertical", display_name="Discussable Unit", ) - unit_non_discussible = ItemFactory.create( + unit_non_discussible = BlockFactory.create( parent=sequence, category="vertical", display_name="Non-Discussable Unit", discussion_enabled=False, ) - graded_sequence = ItemFactory.create( + graded_sequence = BlockFactory.create( parent=section, category="sequential", display_name="Graded Sequence", graded=True, ) - self.graded_unit_discussible = graded_unit_discussible = ItemFactory.create( + self.graded_unit_discussible = graded_unit_discussible = BlockFactory.create( parent=graded_sequence, category="vertical", display_name="Discussable Graded Unit", ) - graded_unit_non_discussible = ItemFactory.create( + graded_unit_non_discussible = BlockFactory.create( parent=graded_sequence, category="vertical", display_name="Non-Discussable Graded Unit", @@ -243,7 +243,7 @@ def add_discussion_block(self, units): Add a discussion block to the specified units. """ for unit in units: - ItemFactory.create( + BlockFactory.create( parent=unit, category='discussion', discussion_id=f'id-{unit.location}', diff --git a/openedx/core/djangoapps/discussions/tests/test_transformer.py b/openedx/core/djangoapps/discussions/tests/test_transformer.py index 3b7bd815f62c..3768eb1ea92a 100644 --- a/openedx/core/djangoapps/discussions/tests/test_transformer.py +++ b/openedx/core/djangoapps/discussions/tests/test_transformer.py @@ -3,7 +3,7 @@ """ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from lms.djangoapps.course_blocks.api import get_course_blocks from lms.djangoapps.course_blocks.transformers.tests.helpers import TransformerRegistryTestMixin @@ -24,15 +24,15 @@ def setUp(self): super().setUp() self.test_topic_id = 'test-topic-id' self.course = CourseFactory.create() - section = ItemFactory.create( + section = BlockFactory.create( parent_location=self.course.location, category="chapter", ) - subsection1 = ItemFactory.create( + subsection1 = BlockFactory.create( parent_location=section.location, category="sequential", ) - self.discussable_unit = ItemFactory.create( + self.discussable_unit = BlockFactory.create( parent_location=subsection1.location, category="vertical", # This won't really be used, but set it anyway @@ -45,7 +45,7 @@ def setUp(self): provider_id=get_default_provider_type(), external_id=self.test_topic_id, ) - self.non_discussable_unit = ItemFactory.create( + self.non_discussable_unit = BlockFactory.create( parent_location=subsection1.location, category="vertical", discussion_enabled=False, diff --git a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_course_update.py b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_course_update.py index d7804d290dc5..72e68b042012 100644 --- a/openedx/core/djangoapps/schedules/management/commands/tests/test_send_course_update.py +++ b/openedx/core/djangoapps/schedules/management/commands/tests/test_send_course_update.py @@ -22,7 +22,7 @@ from openedx.core.djangolib.testing.utils import skip_unless_lms from common.djangoapps.student.tests.factories import CourseEnrollmentFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order @ddt.ddt @@ -65,7 +65,7 @@ def prepare_course_data(self, is_self_paced=True): course = CourseFactory(highlights_enabled_for_messaging=True, self_paced=is_self_paced) with self.store.bulk_operations(course.id): - ItemFactory.create(parent=course, category='chapter', highlights=['highlights']) + BlockFactory.create(parent=course, category='chapter', highlights=['highlights']) enrollment = CourseEnrollmentFactory(course_id=course.id, user=self.user, mode='audit') assert enrollment.schedule.get_experience_type() == ScheduleExperience.EXPERIENCES.course_updates diff --git a/openedx/core/djangoapps/schedules/tests/test_content_highlights.py b/openedx/core/djangoapps/schedules/tests/test_content_highlights.py index 78af33d2aa91..9a34eaee5d25 100644 --- a/openedx/core/djangoapps/schedules/tests/test_content_highlights.py +++ b/openedx/core/djangoapps/schedules/tests/test_content_highlights.py @@ -4,7 +4,7 @@ import pytest from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from openedx.core.djangoapps.schedules.content_highlights import ( course_has_highlights_from_store, @@ -36,7 +36,7 @@ def _setup_user(self): CourseEnrollment.enroll(self.user, self.course_key) def _create_chapter(self, **kwargs): - ItemFactory.create( + BlockFactory.create( parent=self.course, category='chapter', **kwargs diff --git a/openedx/core/djangoapps/schedules/tests/test_resolvers.py b/openedx/core/djangoapps/schedules/tests/test_resolvers.py index 20f9d5d7a9c5..36bc8beacd32 100644 --- a/openedx/core/djangoapps/schedules/tests/test_resolvers.py +++ b/openedx/core/djangoapps/schedules/tests/test_resolvers.py @@ -15,7 +15,7 @@ from edx_toggles.toggles.testutils import override_waffle_switch from testfixtures import LogCapture from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory @@ -144,7 +144,7 @@ def setUp(self): super().setUp() self.course = CourseFactory.create(highlights_enabled_for_messaging=True) with self.store.bulk_operations(self.course.id): - ItemFactory.create(parent=self.course, category='chapter', highlights=['good stuff']) + BlockFactory.create(parent=self.course, category='chapter', highlights=['good stuff']) def create_resolver(self): """ @@ -244,10 +244,10 @@ def setUp(self): ) with self.store.bulk_operations(self.course.id): - ItemFactory.create(parent=self.course, category='chapter', highlights=['good stuff 1']) - ItemFactory.create(parent=self.course, category='chapter', highlights=['good stuff 2']) - ItemFactory.create(parent=self.course, category='chapter', highlights=['good stuff 3']) - ItemFactory.create(parent=self.course, category='chapter', highlights=['good stuff 4']) + BlockFactory.create(parent=self.course, category='chapter', highlights=['good stuff 1']) + BlockFactory.create(parent=self.course, category='chapter', highlights=['good stuff 2']) + BlockFactory.create(parent=self.course, category='chapter', highlights=['good stuff 3']) + BlockFactory.create(parent=self.course, category='chapter', highlights=['good stuff 4']) def create_resolver(self, user_start_date_offset=8): """ diff --git a/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py b/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py index 6559948290df..5755143e4a94 100644 --- a/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py +++ b/openedx/core/djangoapps/user_api/accounts/tests/test_utils.py @@ -12,7 +12,7 @@ from common.djangoapps.student.models import CourseEnrollment from common.djangoapps.student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order from ..utils import format_social_link, validate_social_link @@ -84,10 +84,10 @@ def create_test_course(self): """ course = CourseFactory.create() with self.store.bulk_operations(course.id): - self.chapter = ItemFactory.create(category='chapter', parent=course) - self.sequential = ItemFactory.create(category='sequential', parent=self.chapter) - self.vertical1 = ItemFactory.create(category='vertical', parent=self.sequential) - self.vertical2 = ItemFactory.create(category='vertical', parent=self.sequential) + self.chapter = BlockFactory.create(category='chapter', parent=course) + self.sequential = BlockFactory.create(category='sequential', parent=self.chapter) + self.vertical1 = BlockFactory.create(category='vertical', parent=self.sequential) + self.vertical2 = BlockFactory.create(category='vertical', parent=self.sequential) if hasattr(self, 'user_one'): CourseEnrollment.enroll(self.engaged_user, course.id) diff --git a/openedx/core/djangoapps/util/testing.py b/openedx/core/djangoapps/util/testing.py index f7669d32aa94..f840cad676da 100644 --- a/openedx/core/djangoapps/util/testing.py +++ b/openedx/core/djangoapps/util/testing.py @@ -13,7 +13,7 @@ from openedx.core.lib.teams_config import TeamsConfig from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # 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 Group, UserPartition # lint-amnesty, pylint: disable=wrong-import-order @@ -99,21 +99,21 @@ def setUp(self): partition_id=self.course.user_partitions[0].id, group_id=self.course.user_partitions[0].groups[1].id ) - self.alpha_module = ItemFactory.create( + self.alpha_module = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='alpha_group_discussion', discussion_target='Visible to Alpha', group_access={self.course.user_partitions[0].id: [self.course.user_partitions[0].groups[0].id]} ) - self.beta_module = ItemFactory.create( + self.beta_module = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='beta_group_discussion', discussion_target='Visible to Beta', group_access={self.course.user_partitions[0].id: [self.course.user_partitions[0].groups[1].id]} ) - self.global_module = ItemFactory.create( + self.global_module = BlockFactory.create( parent_location=self.course.location, category='discussion', discussion_id='global_group_discussion', @@ -172,14 +172,14 @@ def setUp(self): }] } ) - chapter = ItemFactory.create(parent_location=self.course.location, - display_name='Chapter') + chapter = BlockFactory.create(parent_location=self.course.location, + display_name='Chapter') # add a sequence to the course to which the problems can be added - self.problem_section = ItemFactory.create(parent_location=chapter.location, - category='sequential', - metadata={'graded': True, 'format': 'Homework'}, - display_name=self.TEST_SECTION_NAME) + self.problem_section = BlockFactory.create(parent_location=chapter.location, + category='sequential', + metadata={'graded': True, 'format': 'Homework'}, + display_name=self.TEST_SECTION_NAME) # Create users and partition them self.student_a = UserFactory.create(username='student_a', email='student_a@example.com') @@ -201,7 +201,7 @@ def setUp(self): ) # Create a vertical to contain our split test - problem_vertical = ItemFactory.create( + problem_vertical = BlockFactory.create( parent_location=self.problem_section.location, category='vertical', display_name='Problem Unit' @@ -210,20 +210,20 @@ def setUp(self): # Create the split test and child vertical containers vertical_a_url = self.course.id.make_usage_key('vertical', 'split_test_vertical_a') vertical_b_url = self.course.id.make_usage_key('vertical', 'split_test_vertical_b') - self.split_test = ItemFactory.create( + self.split_test = BlockFactory.create( parent_location=problem_vertical.location, category='split_test', display_name='Split Test', user_partition_id=self.partition.id, group_id_to_child={str(index): url for index, url in enumerate([vertical_a_url, vertical_b_url])} ) - self.vertical_a = ItemFactory.create( + self.vertical_a = BlockFactory.create( parent_location=self.split_test.location, category='vertical', display_name='Group A problem container', location=vertical_a_url ) - self.vertical_b = ItemFactory.create( + self.vertical_b = BlockFactory.create( parent_location=self.split_test.location, category='vertical', display_name='Group B problem container', diff --git a/openedx/core/djangoapps/xblock/runtime/shims.py b/openedx/core/djangoapps/xblock/runtime/shims.py index 8bf18efad3a1..6215afab34d5 100644 --- a/openedx/core/djangoapps/xblock/runtime/shims.py +++ b/openedx/core/djangoapps/xblock/runtime/shims.py @@ -394,21 +394,3 @@ def has_dynamic_children(self): student when the module is created. This is deprecated and discouraged. """ return False - - def get_display_items(self): - """ - Returns a list of descendent XBlock instances that will display - immediately inside this module. - """ - warnings.warn("get_display_items() is deprecated.", DeprecationWarning, stacklevel=2) - items = [] - for child in self.get_children(): - items.extend(child.displayable_items()) - return items - - def displayable_items(self): - """ - Returns list of displayable modules contained by this XBlock. If this - module is visible, should return [self]. - """ - return [self] diff --git a/openedx/core/lib/gating/tests/test_api.py b/openedx/core/lib/gating/tests/test_api.py index 7214fff42133..816dd722cc49 100644 --- a/openedx/core/lib/gating/tests/test_api.py +++ b/openedx/core/lib/gating/tests/test_api.py @@ -12,7 +12,7 @@ from milestones import api as milestones_api from milestones.tests.utils import MilestonesTestCaseMixin from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import UserFactory from lms.djangoapps.gating import api as lms_gating_api @@ -46,26 +46,26 @@ def setUp(self): self.course.save() # create chapter - self.chapter1 = ItemFactory.create( + self.chapter1 = BlockFactory.create( parent_location=self.course.location, category='chapter', display_name='untitled chapter 1' ) # create sequentials - self.seq1 = ItemFactory.create( + self.seq1 = BlockFactory.create( parent_location=self.chapter1.location, category='sequential', display_name='untitled sequential 1' ) - self.seq2 = ItemFactory.create( + self.seq2 = BlockFactory.create( parent_location=self.chapter1.location, category='sequential', display_name='untitled sequential 2' ) # create vertical - self.vertical = ItemFactory.create( + self.vertical = BlockFactory.create( parent_location=self.seq1.location, category='vertical', display_name='untitled vertical 1' @@ -248,12 +248,12 @@ def test_get_subsection_completion_percentage(self, user_problem_completion, use """ student = UserFactory(is_staff=False) - problem_block = ItemFactory.create( + problem_block = BlockFactory.create( parent_location=self.vertical.location, category='problem', display_name='some problem' ) - html_block = ItemFactory.create( + html_block = BlockFactory.create( parent_location=self.vertical.location, category='html', display_name='some html block' @@ -293,7 +293,7 @@ def test_get_subsection_completion_percentage_single_component( """ student = UserFactory(is_staff=False) - component = ItemFactory.create( + component = BlockFactory.create( parent_location=self.vertical.location, category=component_type, display_name=f'{component_type} block' diff --git a/openedx/core/lib/tests/test_xblock_utils.py b/openedx/core/lib/tests/test_xblock_utils.py index 20dcaa1f02b7..8a10e0220dfb 100644 --- a/openedx/core/lib/tests/test_xblock_utils.py +++ b/openedx/core/lib/tests/test_xblock_utils.py @@ -14,7 +14,7 @@ from xblock.core import XBlockAside from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.modulestore.tests.test_asides import AsideTestType from openedx.core.lib.url_utils import quote_slashes @@ -164,7 +164,7 @@ class TestXBlockAside(SharedModuleStoreTestCase): def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() - cls.block = ItemFactory.create(parent=cls.course) + cls.block = BlockFactory.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") diff --git a/openedx/features/content_type_gating/tests/test_access.py b/openedx/features/content_type_gating/tests/test_access.py index 2ea484210e7f..8c8da08ef863 100644 --- a/openedx/features/content_type_gating/tests/test_access.py +++ b/openedx/features/content_type_gating/tests/test_access.py @@ -16,7 +16,7 @@ from xmodule.modulestore.tests.django_utils import ( TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase, SharedModuleStoreTestCase, ) -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID from lms.djangoapps.course_api.blocks.api import get_blocks @@ -220,9 +220,9 @@ def setUpClass(cls): block_args['weight'] = weight if graded and has_score and weight: block_args['metadata'] = METADATA - block = ItemFactory.create(**block_args) + block = BlockFactory.create(**block_args) # Intersperse HTML so that the content-gating renders in all blocks - ItemFactory.create( + BlockFactory.create( parent=cls.blocks_dict['vertical'], category='html', graded=False, @@ -240,7 +240,7 @@ def setUpClass(cls): scored_lti_metadata.update(METADATA) # add LTI blocks to default course - cls.blocks_dict['lti_block'] = ItemFactory.create( + cls.blocks_dict['lti_block'] = BlockFactory.create( parent=cls.blocks_dict['vertical'], category='lti_consumer', has_score=True, @@ -248,12 +248,12 @@ def setUpClass(cls): metadata=scored_lti_metadata, ) # Intersperse HTML so that the content-gating renders in all blocks - ItemFactory.create( + BlockFactory.create( parent=cls.blocks_dict['vertical'], category='html', graded=False, ) - cls.blocks_dict['lti_block_not_scored'] = ItemFactory.create( + cls.blocks_dict['lti_block_not_scored'] = BlockFactory.create( parent=cls.blocks_dict['vertical'], category='lti_consumer', has_score=False, @@ -261,14 +261,14 @@ def setUpClass(cls): ) # Intersperse HTML so that the content-gating renders in all blocks - ItemFactory.create( + BlockFactory.create( parent=cls.blocks_dict['vertical'], category='html', graded=False, ) # add ungraded problem for xblock_handler test - cls.blocks_dict['graded_problem'] = ItemFactory.create( + cls.blocks_dict['graded_problem'] = BlockFactory.create( parent=cls.blocks_dict['vertical'], category='problem', graded=True, @@ -276,26 +276,26 @@ def setUpClass(cls): ) # Intersperse HTML so that the content-gating renders in all blocks - ItemFactory.create( + BlockFactory.create( parent=cls.blocks_dict['vertical'], category='html', graded=False, ) - cls.blocks_dict['ungraded_problem'] = ItemFactory.create( + cls.blocks_dict['ungraded_problem'] = BlockFactory.create( parent=cls.blocks_dict['vertical'], category='problem', graded=False, ) # Intersperse HTML so that the content-gating renders in all blocks - ItemFactory.create( + BlockFactory.create( parent=cls.blocks_dict['vertical'], category='html', graded=False, ) - cls.blocks_dict['audit_visible_graded_problem'] = ItemFactory.create( + cls.blocks_dict['audit_visible_graded_problem'] = BlockFactory.create( parent=cls.blocks_dict['vertical'], category='problem', graded=True, @@ -308,7 +308,7 @@ def setUpClass(cls): ) # Intersperse HTML so that the content-gating renders in all blocks - ItemFactory.create( + BlockFactory.create( parent=cls.blocks_dict['vertical'], category='html', graded=False, @@ -409,28 +409,28 @@ def _create_course(cls, run, display_name, modes, component_types, expired_upgra with cls.store.bulk_operations(course.id): blocks_dict = {} - chapter = ItemFactory.create( + chapter = BlockFactory.create( parent=course, display_name='Overview', ) - blocks_dict['chapter'] = ItemFactory.create( + blocks_dict['chapter'] = BlockFactory.create( parent=course, category='chapter', display_name='Week 1', ) - blocks_dict['sequential'] = ItemFactory.create( + blocks_dict['sequential'] = BlockFactory.create( parent=chapter, category='sequential', display_name='Lesson 1', ) - blocks_dict['vertical'] = ItemFactory.create( + blocks_dict['vertical'] = BlockFactory.create( parent=blocks_dict['sequential'], category='vertical', display_name='Lesson 1 Vertical - Unit 1', ) for component_type in component_types: - block = ItemFactory.create( + block = BlockFactory.create( parent=blocks_dict['vertical'], category=component_type, graded=True, @@ -438,7 +438,7 @@ def _create_course(cls, run, display_name, modes, component_types, expired_upgra ) blocks_dict[component_type] = block # Intersperse HTML so that the content-gating renders in all blocks - ItemFactory.create( + BlockFactory.create( parent=blocks_dict['vertical'], category='html', graded=False, @@ -834,12 +834,12 @@ def setUp(self): value='1', ) # Create blocks to go into the verticals - self.block_a = ItemFactory.create( + self.block_a = BlockFactory.create( category='problem', parent=self.vertical_a, metadata=METADATA, ) - self.block_b = ItemFactory.create( + self.block_b = BlockFactory.create( category='problem', parent=self.vertical_b, metadata=METADATA, @@ -918,17 +918,17 @@ def _create_course(self): # pylint: disable=missing-function-docstring CourseModeFactory.create(course_id=course.id, mode_slug='verified') blocks_dict = {} with self.store.bulk_operations(course.id): - blocks_dict['chapter'] = ItemFactory.create( + blocks_dict['chapter'] = BlockFactory.create( parent=course, category='chapter', display_name='Week 1' ) - blocks_dict['sequential'] = ItemFactory.create( + blocks_dict['sequential'] = BlockFactory.create( parent=blocks_dict['chapter'], category='sequential', display_name='Lesson 1' ) - blocks_dict['vertical'] = ItemFactory.create( + blocks_dict['vertical'] = BlockFactory.create( parent=blocks_dict['sequential'], category='vertical', display_name='Lesson 1 Vertical - Unit 1' @@ -947,7 +947,7 @@ def test_single_denied(self): course_id=course['course'].id, mode='audit' ) - blocks_dict['graded_1'] = ItemFactory.create( + blocks_dict['graded_1'] = BlockFactory.create( parent_location=blocks_dict['vertical'].location, category='problem', graded=True, @@ -966,13 +966,13 @@ def test_double_denied(self): ''' First graded problem should show message, second shouldn't ''' course = self._create_course() blocks_dict = course['blocks'] - blocks_dict['graded_1'] = ItemFactory.create( + blocks_dict['graded_1'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, metadata=METADATA, ) - blocks_dict['graded_2'] = ItemFactory.create( + blocks_dict['graded_2'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, @@ -1003,25 +1003,25 @@ def test_many_denied(self): ''' First graded problem should show message, all that follow shouldn't ''' course = self._create_course() blocks_dict = course['blocks'] - blocks_dict['graded_1'] = ItemFactory.create( + blocks_dict['graded_1'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, metadata=METADATA, ) - blocks_dict['graded_2'] = ItemFactory.create( + blocks_dict['graded_2'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, metadata=METADATA, ) - blocks_dict['graded_3'] = ItemFactory.create( + blocks_dict['graded_3'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, metadata=METADATA, ) - blocks_dict['graded_4'] = ItemFactory.create( + blocks_dict['graded_4'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, @@ -1066,18 +1066,18 @@ def test_alternate_denied(self): ''' Multiple graded content with ungraded between it should show message on either end ''' course = self._create_course() blocks_dict = course['blocks'] - blocks_dict['graded_1'] = ItemFactory.create( + blocks_dict['graded_1'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, metadata=METADATA, ) - blocks_dict['ungraded_2'] = ItemFactory.create( + blocks_dict['ungraded_2'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=False, ) - blocks_dict['graded_3'] = ItemFactory.create( + blocks_dict['graded_3'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, @@ -1138,17 +1138,17 @@ def _create_course(self): # pylint: disable=missing-function-docstring CourseModeFactory.create(course_id=course.id, mode_slug='verified') blocks_dict = {} with self.store.bulk_operations(course.id): - blocks_dict['chapter'] = ItemFactory.create( + blocks_dict['chapter'] = BlockFactory.create( parent=course, category='chapter', display_name='Week 1' ) - blocks_dict['sequential'] = ItemFactory.create( + blocks_dict['sequential'] = BlockFactory.create( parent=blocks_dict['chapter'], category='sequential', display_name='Lesson 1' ) - blocks_dict['vertical'] = ItemFactory.create( + blocks_dict['vertical'] = BlockFactory.create( parent=blocks_dict['sequential'], category='vertical', display_name='Lesson 1 Vertical - Unit 1' @@ -1169,13 +1169,13 @@ def test_content_type_gate_for_block(self): course_id=course['course'].id, mode='audit' ) - blocks_dict['graded_1'] = ItemFactory.create( + blocks_dict['graded_1'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, metadata=METADATA, ) - blocks_dict['not_graded_1'] = ItemFactory.create( + blocks_dict['not_graded_1'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=False, @@ -1202,7 +1202,7 @@ def test_check_children_for_content_type_gating_paywall(self, mocked_user): # p course_id=course['course'].id, mode='audit' ) - blocks_dict['not_graded_1'] = ItemFactory.create( + blocks_dict['not_graded_1'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=False, @@ -1217,7 +1217,7 @@ def test_check_children_for_content_type_gating_paywall(self, mocked_user): # p blocks_dict['vertical'], course['course'].id ) is None - blocks_dict['graded_1'] = ItemFactory.create( + blocks_dict['graded_1'] = BlockFactory.create( parent=blocks_dict['vertical'], category='problem', graded=True, diff --git a/openedx/features/course_bookmarks/tests/test_course_bookmarks.py b/openedx/features/course_bookmarks/tests/test_course_bookmarks.py index 264bc26e4448..313ea3d3b15a 100644 --- a/openedx/features/course_bookmarks/tests/test_course_bookmarks.py +++ b/openedx/features/course_bookmarks/tests/test_course_bookmarks.py @@ -8,7 +8,7 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import CourseUserType, SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from ..plugins import CourseBookmarksTool @@ -29,9 +29,9 @@ def setUpClass(cls): cls.course = CourseFactory.create() with cls.store.bulk_operations(cls.course.id): # Create a basic course structure - chapter = ItemFactory.create(category='chapter', parent_location=cls.course.location) - section = ItemFactory.create(category='sequential', parent_location=chapter.location) - ItemFactory.create(category='vertical', parent_location=section.location) + chapter = BlockFactory.create(category='chapter', parent_location=cls.course.location) + section = BlockFactory.create(category='sequential', parent_location=chapter.location) + BlockFactory.create(category='vertical', parent_location=section.location) @ddt.data( [CourseUserType.ANONYMOUS, False], diff --git a/openedx/features/course_duration_limits/tests/test_course_expiration.py b/openedx/features/course_duration_limits/tests/test_course_expiration.py index 2db8c1d1a65b..32a352d66e6e 100644 --- a/openedx/features/course_duration_limits/tests/test_course_expiration.py +++ b/openedx/features/course_duration_limits/tests/test_course_expiration.py @@ -10,7 +10,7 @@ from django.urls import reverse from django.utils.timezone import now from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID from common.djangoapps.course_modes.models import CourseMode @@ -49,17 +49,17 @@ def setUp(self): self.course = CourseFactory( start=now() - timedelta(weeks=10), ) - self.chapter = ItemFactory.create( + self.chapter = BlockFactory.create( category='chapter', parent_location=self.course.location, display_name='Test Chapter' ) - self.sequential = ItemFactory.create( + self.sequential = BlockFactory.create( category='sequential', parent_location=self.chapter.location, display_name='Test Sequential' ) - ItemFactory.create( + BlockFactory.create( category='vertical', parent_location=self.sequential.location, display_name='Test Vertical' diff --git a/openedx/features/course_experience/tests/__init__.py b/openedx/features/course_experience/tests/__init__.py index 4b93ba925121..9581c095a446 100644 --- a/openedx/features/course_experience/tests/__init__.py +++ b/openedx/features/course_experience/tests/__init__.py @@ -9,7 +9,7 @@ from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order class BaseCourseUpdatesTestCase(SharedModuleStoreTestCase): @@ -23,9 +23,9 @@ def setUpClass(cls): cls.course = CourseFactory.create() with cls.store.bulk_operations(cls.course.id): # Create a basic course structure - chapter = ItemFactory.create(category='chapter', parent_location=cls.course.location) - section = ItemFactory.create(category='sequential', parent_location=chapter.location) - ItemFactory.create(category='vertical', parent_location=section.location) + chapter = BlockFactory.create(category='chapter', parent_location=cls.course.location) + section = BlockFactory.create(category='sequential', parent_location=chapter.location) + BlockFactory.create(category='vertical', parent_location=section.location) @classmethod def setUpTestData(cls): diff --git a/openedx/features/course_experience/tests/test_url_helpers.py b/openedx/features/course_experience/tests/test_url_helpers.py index 00414d70eec0..dfa84583ab28 100644 --- a/openedx/features/course_experience/tests/test_url_helpers.py +++ b/openedx/features/course_experience/tests/test_url_helpers.py @@ -9,7 +9,7 @@ from django.test.utils import override_settings from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from .. import url_helpers @@ -90,22 +90,22 @@ def create_test_courses(cls): display_name='URL Helpers Test Course', ) with cls.store.bulk_operations(course_run.id): - section = ItemFactory.create( + section = BlockFactory.create( parent_location=course_run.location, category='chapter', display_name="Generated Section", ) - subsection = ItemFactory.create( + subsection = BlockFactory.create( parent_location=section.location, category='sequential', display_name="Generated Subsection", ) - unit = ItemFactory.create( + unit = BlockFactory.create( parent_location=subsection.location, category='vertical', display_name="Generated Unit", ) - component = ItemFactory.create( + component = BlockFactory.create( parent_location=unit.location, category='problem', display_name="Generated Problem Component", diff --git a/openedx/features/enterprise_support/tests/test_utils.py b/openedx/features/enterprise_support/tests/test_utils.py index ec271de137d5..fbf2cccf9dbc 100644 --- a/openedx/features/enterprise_support/tests/test_utils.py +++ b/openedx/features/enterprise_support/tests/test_utils.py @@ -47,7 +47,7 @@ update_third_party_auth_context_for_enterprise ) from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order TEST_PASSWORD = 'test' @@ -569,16 +569,16 @@ def create_test_course(cls): """ course = CourseFactory.create() with cls.store.bulk_operations(course.id): - chapter = ItemFactory.create(category='chapter', parent_location=course.location) - chapter2 = ItemFactory.create(category='chapter', parent_location=course.location) - sequential = ItemFactory.create(category='sequential', parent_location=chapter.location) - sequential2 = ItemFactory.create(category='sequential', parent_location=chapter.location) - sequential3 = ItemFactory.create(category='sequential', parent_location=chapter2.location) - sequential4 = ItemFactory.create(category='sequential', parent_location=chapter2.location) - vertical = ItemFactory.create(category='vertical', parent_location=sequential.location) - vertical2 = ItemFactory.create(category='vertical', parent_location=sequential2.location) - vertical3 = ItemFactory.create(category='vertical', parent_location=sequential3.location) - vertical4 = ItemFactory.create(category='vertical', parent_location=sequential4.location) + chapter = BlockFactory.create(category='chapter', parent_location=course.location) + chapter2 = BlockFactory.create(category='chapter', parent_location=course.location) + sequential = BlockFactory.create(category='sequential', parent_location=chapter.location) + sequential2 = BlockFactory.create(category='sequential', parent_location=chapter.location) + sequential3 = BlockFactory.create(category='sequential', parent_location=chapter2.location) + sequential4 = BlockFactory.create(category='sequential', parent_location=chapter2.location) + vertical = BlockFactory.create(category='vertical', parent_location=sequential.location) + vertical2 = BlockFactory.create(category='vertical', parent_location=sequential2.location) + vertical3 = BlockFactory.create(category='vertical', parent_location=sequential3.location) + vertical4 = BlockFactory.create(category='vertical', parent_location=sequential4.location) course.children = [chapter, chapter2] chapter.children = [sequential, sequential2] chapter2.children = [sequential3, sequential4] diff --git a/openedx/features/personalized_learner_schedules/call_to_action.py b/openedx/features/personalized_learner_schedules/call_to_action.py index 4852daea3f62..530b4838c0f7 100644 --- a/openedx/features/personalized_learner_schedules/call_to_action.py +++ b/openedx/features/personalized_learner_schedules/call_to_action.py @@ -57,7 +57,7 @@ def get_ctas(self, xblock, category, completed): elif category == self.VERTICAL_BANNER and not completed and missed_deadlines: # xblock is a vertical, so we'll check all the problems inside it. If there are any that will show a # a "shift dates" CTA under CAPA_SUBMIT_DISABLED, then we'll also show the same CTA as a vertical banner. - if any(self._is_block_shiftable(item, category) for item in xblock.get_display_items()): + if any(self._is_block_shiftable(item, category) for item in xblock.get_children()): ctas.append(self._make_reset_deadlines_cta(xblock, category, is_learning_mfe)) return ctas diff --git a/openedx/tests/completion_integration/test_services.py b/openedx/tests/completion_integration/test_services.py index eef0247e7136..9761d7bfe34b 100644 --- a/openedx/tests/completion_integration/test_services.py +++ b/openedx/tests/completion_integration/test_services.py @@ -12,7 +12,7 @@ from opaque_keys.edx.keys import CourseKey from xmodule.library_tools import LibraryToolsService from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, LibraryFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, LibraryFactory from xmodule.tests import get_test_system from openedx.core.djangolib.testing.utils import skip_unless_lms @@ -30,47 +30,47 @@ def setUpClass(cls): super().setUpClass() cls.course = CourseFactory.create() with cls.store.bulk_operations(cls.course.id): - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, category="chapter", publish_item=False, ) - cls.sequence = ItemFactory.create( + cls.sequence = BlockFactory.create( parent=cls.chapter, category='sequential', publish_item=False, ) - cls.vertical = ItemFactory.create( + cls.vertical = BlockFactory.create( parent=cls.sequence, category='vertical', publish_item=False, ) - cls.html = ItemFactory.create( + cls.html = BlockFactory.create( parent=cls.vertical, category='html', publish_item=False, ) - cls.problem = ItemFactory.create( + cls.problem = BlockFactory.create( parent=cls.vertical, category="problem", publish_item=False, ) - cls.problem2 = ItemFactory.create( + cls.problem2 = BlockFactory.create( parent=cls.vertical, category="problem", publish_item=False, ) - cls.problem3 = ItemFactory.create( + cls.problem3 = BlockFactory.create( parent=cls.vertical, category="problem", publish_item=False, ) - cls.problem4 = ItemFactory.create( + cls.problem4 = BlockFactory.create( parent=cls.vertical, category="problem", publish_item=False, ) - cls.problem5 = ItemFactory.create( + cls.problem5 = BlockFactory.create( parent=cls.vertical, category="problem", publish_item=False, @@ -186,8 +186,8 @@ def test_can_mark_block_complete_on_view(self): @override_settings(FEATURES={**settings.FEATURES, 'MARK_LIBRARY_CONTENT_BLOCK_COMPLETE_ON_VIEW': True}) def test_can_mark_library_content_complete_on_view(self): library = LibraryFactory.create(modulestore=self.store) - lib_vertical = ItemFactory.create(parent=self.sequence, category='vertical', publish_item=False) - library_content_block = ItemFactory.create( + lib_vertical = BlockFactory.create(parent=self.sequence, category='vertical', publish_item=False) + library_content_block = BlockFactory.create( parent=lib_vertical, category='library_content', max_count=1, @@ -198,19 +198,19 @@ def test_can_mark_library_content_complete_on_view(self): def test_vertical_completion_with_library_content(self): library = LibraryFactory.create(modulestore=self.store) - ItemFactory.create(parent=library, category='problem', publish_item=False, user_id=self.user.id) - ItemFactory.create(parent=library, category='problem', publish_item=False, user_id=self.user.id) - ItemFactory.create(parent=library, category='problem', publish_item=False, user_id=self.user.id) + BlockFactory.create(parent=library, category='problem', publish_item=False, user_id=self.user.id) + BlockFactory.create(parent=library, category='problem', publish_item=False, user_id=self.user.id) + BlockFactory.create(parent=library, category='problem', publish_item=False, user_id=self.user.id) # Create a new vertical to hold the library content block # It is very important that we use parent_location=self.sequence.location (and not parent=self.sequence), since # sequence is a class attribute and passing it by value will update its .children=[] which will then leak into # other tests and cause errors if the children no longer exist. - lib_vertical = ItemFactory.create( + lib_vertical = BlockFactory.create( parent_location=self.sequence.location, category='vertical', publish_item=False, ) - library_content_block = ItemFactory.create( + library_content_block = BlockFactory.create( parent=lib_vertical, category='library_content', max_count=1, @@ -262,9 +262,9 @@ def test_vertical_completion_with_nested_children(self): # It is very important that we use parent_location=self.sequence.location (and not parent=self.sequence), since # sequence is a class attribute and passing it by value will update its .children=[] which will then leak into # other tests and cause errors if the children no longer exist. - parent_vertical = ItemFactory(parent_location=self.sequence.location, category='vertical') - extra_vertical = ItemFactory(parent=parent_vertical, category='vertical') - problem = ItemFactory(parent=extra_vertical, category='problem') + parent_vertical = BlockFactory(parent_location=self.sequence.location, category='vertical') + extra_vertical = BlockFactory(parent=parent_vertical, category='vertical') + problem = BlockFactory(parent=extra_vertical, category='problem') parent_vertical = self.store.get_item(parent_vertical.location) # Nothing is complete diff --git a/openedx/tests/completion_integration/test_views.py b/openedx/tests/completion_integration/test_views.py index 607f2051d09e..e9e866224ec4 100644 --- a/openedx/tests/completion_integration/test_views.py +++ b/openedx/tests/completion_integration/test_views.py @@ -14,7 +14,7 @@ from common.djangoapps.student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory # lint-amnesty, pylint: disable=wrong-import-order +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order @ddt.ddt @@ -45,7 +45,7 @@ def setUp(self): default_store=ModuleStoreEnum.Type.split, ) assert str(self.course.id) == self.COURSE_KEY - self.problem = ItemFactory.create( + self.problem = BlockFactory.create( parent=self.course, category="problem", display_name="Test Problem", publish_item=False, ) assert str(self.problem.location) == self.BLOCK_KEY diff --git a/openedx/tests/xblock_integration/test_crowdsource_hinter.py b/openedx/tests/xblock_integration/test_crowdsource_hinter.py index fedd1e91ca77..a2fffdc6e90c 100644 --- a/openedx/tests/xblock_integration/test_crowdsource_hinter.py +++ b/openedx/tests/xblock_integration/test_crowdsource_hinter.py @@ -9,7 +9,7 @@ from django.conf import settings from django.urls import reverse from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import GlobalStaffFactory from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase @@ -39,16 +39,16 @@ def setUpClass(cls): display_name='CrowdsourceHinter_Test_Course' ) with cls.store.bulk_operations(cls.course.id, emit_signals=False): - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, display_name='Overview' ) - cls.section = ItemFactory.create( + cls.section = BlockFactory.create( parent=cls.chapter, display_name='Welcome' ) - cls.unit = ItemFactory.create( + cls.unit = BlockFactory.create( parent=cls.section, display_name='New Unit' ) - cls.xblock = ItemFactory.create( + cls.xblock = BlockFactory.create( parent=cls.unit, category='crowdsourcehinter', display_name='crowdsourcehinter' diff --git a/openedx/tests/xblock_integration/test_recommender.py b/openedx/tests/xblock_integration/test_recommender.py index d312f8892573..a494fc9c13c2 100644 --- a/openedx/tests/xblock_integration/test_recommender.py +++ b/openedx/tests/xblock_integration/test_recommender.py @@ -15,7 +15,7 @@ from django.conf import settings from django.urls import reverse from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from common.djangoapps.student.tests.factories import GlobalStaffFactory from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase @@ -45,21 +45,21 @@ def setUpClass(cls): display_name='Recommender_Test_Course' ) with cls.store.bulk_operations(cls.course.id, emit_signals=False): - cls.chapter = ItemFactory.create( + cls.chapter = BlockFactory.create( parent=cls.course, display_name='Overview' ) - cls.section = ItemFactory.create( + cls.section = BlockFactory.create( parent=cls.chapter, display_name='Welcome' ) - cls.unit = ItemFactory.create( + cls.unit = BlockFactory.create( parent=cls.section, display_name='New Unit' ) - cls.xblock = ItemFactory.create( + cls.xblock = BlockFactory.create( parent=cls.unit, category='recommender', display_name='recommender' ) - cls.xblock2 = ItemFactory.create( + cls.xblock2 = BlockFactory.create( parent=cls.unit, category='recommender', display_name='recommender_second' diff --git a/openedx/tests/xblock_integration/xblock_testcase.py b/openedx/tests/xblock_integration/xblock_testcase.py index eba5d3b90c51..e75ca9a63d41 100644 --- a/openedx/tests/xblock_integration/xblock_testcase.py +++ b/openedx/tests/xblock_integration/xblock_testcase.py @@ -52,7 +52,7 @@ import xmodule.services from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from lms.djangoapps.courseware.tests.helpers import LoginEnrollmentTestCase @@ -240,17 +240,17 @@ def setUpClass(cls): cls.xblocks = {} with cls.store.bulk_operations(cls.course.id, emit_signals=False): for chapter_config in cls.test_configuration: - chapter = ItemFactory.create( + chapter = BlockFactory.create( parent_location=cls.course.location, display_name="ch_" + chapter_config['urlname'], category='chapter' ) - section = ItemFactory.create( + section = BlockFactory.create( parent=chapter, display_name="sec_" + chapter_config['urlname'], category='sequential' ) - unit = ItemFactory.create( + unit = BlockFactory.create( parent=section, display_name='unit_' + chapter_config['urlname'], category='vertical' @@ -264,7 +264,7 @@ def setUpClass(cls): ) for xblock_config in chapter_config['xblocks']: - xblock = ItemFactory.create( + xblock = BlockFactory.create( parent=unit, category=xblock_config['blocktype'], display_name=xblock_config['urlname'], diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index db6dd2100f4a..c7e47aeede34 100644 --- a/xmodule/conditional_block.py +++ b/xmodule/conditional_block.py @@ -287,7 +287,7 @@ def handle_ajax(self, _dispatch, _data): html = self.runtime.service(self, 'mako').render_template('conditional_block.html', context) return json.dumps({'fragments': [{'content': html}], 'message': bool(self.conditional_message)}) - fragments = [child.render(STUDENT_VIEW).to_dict() for child in self.get_display_items()] + fragments = [child.render(STUDENT_VIEW).to_dict() for child in self.get_children()] return json.dumps({'fragments': fragments}) @@ -326,7 +326,7 @@ def get_required_module_descriptors(self): descriptors = [] for location in self.sources_list: try: - descriptor = self.system.load_item(location) + descriptor = self.runtime.get_block(location) descriptors.append(descriptor) except ItemNotFoundError: msg = "Invalid module by location." diff --git a/xmodule/library_content_block.py b/xmodule/library_content_block.py index 94bf54fec08f..ee8dbfeb76eb 100644 --- a/xmodule/library_content_block.py +++ b/xmodule/library_content_block.py @@ -399,13 +399,13 @@ def student_view(self, context): # lint-amnesty, pylint: disable=missing-functi # 500-response. logger.error('Skipping display for child block that is None') continue - for displayable in child.displayable_items(): - rendered_child = displayable.render(STUDENT_VIEW, child_context) - fragment.add_fragment_resources(rendered_child) - contents.append({ - 'id': str(displayable.location), - 'content': rendered_child.content, - }) + + rendered_child = child.render(STUDENT_VIEW, child_context) + fragment.add_fragment_resources(rendered_child) + contents.append({ + 'id': str(child.location), + 'content': rendered_child.content, + }) fragment.add_content(self.runtime.service(self, 'mako').render_template('vert_module.html', { 'items': contents, diff --git a/xmodule/modulestore/mongo/base.py b/xmodule/modulestore/mongo/base.py index a8fa670e4796..93e09dda3cbd 100644 --- a/xmodule/modulestore/mongo/base.py +++ b/xmodule/modulestore/mongo/base.py @@ -824,7 +824,7 @@ def _load_item(self, course_key, item, data_cache, system = using_descriptor_system system.module_data.update(data_cache) - item = system.load_item(location, for_parent=for_parent) + item = system.get_block(location, for_parent=for_parent) # TODO Once TNL-5092 is implemented, we can remove the following line # of code. Until then, set the course_version field on the block to be diff --git a/xmodule/modulestore/tests/django_utils.py b/xmodule/modulestore/tests/django_utils.py index ebbc6eec6523..fcc01763fdc7 100644 --- a/xmodule/modulestore/tests/django_utils.py +++ b/xmodule/modulestore/tests/django_utils.py @@ -511,7 +511,7 @@ class FooTest(ModuleStoreTestCase): MODULESTORE = mixed_store_config(data_dir, mappings) # ... - 3. Use factories (e.g. `CourseFactory`, `ItemFactory`) to populate + 3. Use factories (e.g. `CourseFactory`, `BlockFactory`) to populate the modulestore with test data. NOTE: diff --git a/xmodule/modulestore/tests/factories.py b/xmodule/modulestore/tests/factories.py index 4b8f7a37ec91..bc6bf6ad9649 100644 --- a/xmodule/modulestore/tests/factories.py +++ b/xmodule/modulestore/tests/factories.py @@ -279,7 +279,7 @@ def _create(cls, target_class, **kwargs): # lint-amnesty, pylint: disable=argum return new_library -class ItemFactory(XModuleFactory): +class BlockFactory(XModuleFactory): """ Factory for XModule items. """ diff --git a/xmodule/modulestore/tests/test_libraries.py b/xmodule/modulestore/tests/test_libraries.py index d607c0e7e903..2a82db889b5f 100644 --- a/xmodule/modulestore/tests/test_libraries.py +++ b/xmodule/modulestore/tests/test_libraries.py @@ -10,7 +10,7 @@ from opaque_keys.edx.locator import LibraryLocator from xmodule.modulestore.exceptions import DuplicateCourseError -from xmodule.modulestore.tests.factories import ItemFactory, LibraryFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import BlockFactory, LibraryFactory, check_mongo_calls from xmodule.modulestore.tests.utils import MixedSplitTestCase @@ -80,14 +80,14 @@ def test_block_with_children(self): library = LibraryFactory.create(modulestore=self.store) # In the library, create a vertical block with a child: - vert_block = ItemFactory.create( + vert_block = BlockFactory.create( category="vertical", parent_location=library.location, user_id=self.user_id, publish_item=False, modulestore=self.store, ) - child_block = ItemFactory.create( + child_block = BlockFactory.create( category="html", parent_location=vert_block.location, user_id=self.user_id, @@ -103,7 +103,7 @@ def test_update_item(self): """ library = LibraryFactory.create(modulestore=self.store) - block = ItemFactory.create( + block = BlockFactory.create( category="html", parent_location=library.location, user_id=self.user_id, @@ -128,7 +128,7 @@ def test_delete_item(self): """ library = LibraryFactory.create(modulestore=self.store) lib_key = library.location.library_key - block = ItemFactory.create( + block = BlockFactory.create( category="html", parent_location=library.location, user_id=self.user_id, @@ -191,7 +191,7 @@ def test_get_lib_version(self): def test_xblock_in_lib_have_published_version_returns_false(self): library = LibraryFactory.create(modulestore=self.store) - block = ItemFactory.create( + block = BlockFactory.create( category="html", parent_location=library.location, user_id=self.user_id, diff --git a/xmodule/modulestore/tests/test_mixed_modulestore.py b/xmodule/modulestore/tests/test_mixed_modulestore.py index 0f3298896241..21c25347ba3d 100644 --- a/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -448,7 +448,7 @@ def test_course_version_on_block(self, default_ms): assert block.course_version == course_version # ensure that when the block is retrieved from the runtime cache, # the course version is still present - cached_block = course.runtime.load_item(block.location) + cached_block = course.runtime.get_block(block.location) assert cached_block.course_version == block.course_version @ddt.data((ModuleStoreEnum.Type.split, 2, False), (ModuleStoreEnum.Type.mongo, 3, True)) diff --git a/xmodule/modulestore/tests/test_publish.py b/xmodule/modulestore/tests/test_publish.py index 68e437486044..25f9df78ecd8 100644 --- a/xmodule/modulestore/tests/test_publish.py +++ b/xmodule/modulestore/tests/test_publish.py @@ -20,7 +20,7 @@ from xmodule.exceptions import InvalidVersionError from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.exceptions import ItemNotFoundError -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory, check_mongo_calls from xmodule.modulestore.tests.test_split_w_old_mongo import SplitWMongoCourseBootstrapper from xmodule.modulestore.tests.utils import ( DRAFT_MODULESTORE_SETUP, @@ -217,7 +217,7 @@ def _create_binary_structure_items(parent_type, block_type, num_items, child_blo parent_id = _make_block_id(parent_type, idx // 2) parent_item = getattr(self, parent_id) block_id = _make_block_id(block_type, idx) - setattr(self, block_id, ItemFactory.create( + setattr(self, block_id, BlockFactory.create( parent_location=parent_item.location, category=block_type, modulestore=store, diff --git a/xmodule/modulestore/tests/utils.py b/xmodule/modulestore/tests/utils.py index e5d8d4619aaf..a0a4f79b62a7 100644 --- a/xmodule/modulestore/tests/utils.py +++ b/xmodule/modulestore/tests/utils.py @@ -19,7 +19,7 @@ from xmodule.modulestore.mongo.draft import DraftModuleStore from xmodule.modulestore.split_mongo.split_draft import DraftVersioningModuleStore from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, TEST_DATA_ONLY_SPLIT_MODULESTORE_DRAFT_PREFERRED -from xmodule.modulestore.tests.factories import ItemFactory +from xmodule.modulestore.tests.factories import BlockFactory from xmodule.modulestore.tests.mongo_connection import MONGO_HOST, MONGO_PORT_NUM from xmodule.modulestore.xml import XMLModuleStore from xmodule.tests import DATA_DIR @@ -109,7 +109,7 @@ def make_block(self, category, parent_block, **kwargs): """ extra = {"publish_item": False, "user_id": self.user_id} extra.update(kwargs) - return ItemFactory.create( + return BlockFactory.create( category=category, parent=parent_block, parent_location=parent_block.location, @@ -135,7 +135,7 @@ def descend(parent, stack): xblock_type = stack[0] for _ in range(branching): - child = ItemFactory.create( + child = BlockFactory.create( category=xblock_type, parent=parent, user_id=user_id diff --git a/xmodule/modulestore/xml.py b/xmodule/modulestore/xml.py index d621d6c47796..35c5244c130b 100644 --- a/xmodule/modulestore/xml.py +++ b/xmodule/modulestore/xml.py @@ -639,7 +639,7 @@ def _load_extra_content(self, system, course_descriptor, category, content_path, else: try: # get and update data field in xblock runtime - module = system.load_item(loc) + module = system.get_block(loc) for key, value in data_content.items(): setattr(module, key, value) module.save() @@ -653,7 +653,7 @@ def _load_extra_content(self, system, course_descriptor, category, content_path, # html file with html data content html = f.read() try: - module = system.load_item(loc) + module = system.get_block(loc) module.data = html module.save() except ItemNotFoundError: diff --git a/xmodule/seq_block.py b/xmodule/seq_block.py index 15301685ee10..8e97a3e85953 100644 --- a/xmodule/seq_block.py +++ b/xmodule/seq_block.py @@ -379,7 +379,7 @@ def get_metadata(self, view=STUDENT_VIEW, context=None): prereq_met = True prereq_meta_info = {} banner_text = None - display_items = self.get_display_items() + children = self.get_children() course = self._get_course() is_hidden_after_due = False @@ -399,7 +399,7 @@ def get_metadata(self, view=STUDENT_VIEW, context=None): else: is_hidden_after_due = True - meta = self._get_render_metadata(context, display_items, prereq_met, prereq_meta_info, banner_text, view) + meta = self._get_render_metadata(context, children, prereq_met, prereq_meta_info, banner_text, view) meta['display_name'] = self.display_name_with_default meta['format'] = getattr(self, 'format', '') meta['is_hidden_after_due'] = is_hidden_after_due @@ -567,7 +567,7 @@ def is_user_authenticated(self, context): # NOTE (CCB): We default to true to maintain the behavior in place prior to allowing anonymous access access. return context.get('user_authenticated', True) - def _get_render_metadata(self, context, display_items, prereq_met, prereq_meta_info, banner_text=None, + def _get_render_metadata(self, context, children, prereq_met, prereq_meta_info, banner_text=None, view=STUDENT_VIEW, fragment=None): """Returns a dictionary of sequence metadata, used by render methods and for the courseware API""" if prereq_met and not self._is_gate_fulfilled(): @@ -576,10 +576,10 @@ def _get_render_metadata(self, context, display_items, prereq_met, prereq_meta_i 'This section is a prerequisite. You must complete this section in order to unlock additional content.' ) - items = self._render_student_view_for_items(context, display_items, fragment, view) if prereq_met else [] + blocks = self._render_student_view_for_blocks(context, children, fragment, view) if prereq_met else [] params = { - 'items': items, + 'items': blocks, 'element_id': self.location.html_id(), 'item_id': str(self.location), 'is_time_limited': self.is_time_limited, @@ -606,19 +606,19 @@ def _student_or_public_view(self, context, prereq_met, prereq_meta_info, banner_ content. """ _ = self.runtime.service(self, "i18n").ugettext - display_items = self.get_display_items() - self._update_position(context, len(display_items)) + children = self.get_children() + self._update_position(context, len(children)) fragment = Fragment() - params = self._get_render_metadata(context, display_items, prereq_met, prereq_meta_info, banner_text, view, fragment) # lint-amnesty, pylint: disable=line-too-long + params = self._get_render_metadata(context, children, prereq_met, prereq_meta_info, banner_text, view, fragment) # lint-amnesty, pylint: disable=line-too-long if SHOW_PROGRESS_BAR.is_enabled() and getattr(settings, 'COMPLETION_AGGREGATOR_URL', ''): parent_block_id = self.get_parent().scope_ids.usage_id.block_id params['chapter_completion_aggregator_url'] = '/'.join( [settings.COMPLETION_AGGREGATOR_URL, str(self.scope_ids.usage_id.context_key), parent_block_id]) + '/' fragment.add_content(self.runtime.service(self, 'mako').render_template("seq_block.html", params)) - self._capture_full_seq_item_metrics(display_items) - self._capture_current_unit_metrics(display_items) + self._capture_full_seq_item_metrics(children) + self._capture_current_unit_metrics(children) add_webpack_to_fragment(fragment, 'SequenceBlockPreview') shim_xmodule_js(fragment, 'Sequence') @@ -740,10 +740,10 @@ def _compute_is_prereq_met(self, recalc_on_unmet): return True, {} - def _update_position(self, context, number_of_display_items): + def _update_position(self, context, number_of_children): """ Update the user's sequential position given the context and the - number_of_display_items + number_of_children """ position = context.get('position') @@ -751,25 +751,25 @@ def _update_position(self, context, number_of_display_items): self.position = position # If we're rendering this sequence, but no position is set yet, - # or exceeds the length of the displayable items, + # or exceeds the length of the displayable blocks, # default the position to the first element if context.get('requested_child') == 'first': self.position = 1 elif context.get('requested_child') == 'last': - self.position = number_of_display_items or 1 - elif self.position is None or self.position > number_of_display_items: + self.position = number_of_children or 1 + elif self.position is None or self.position > number_of_children: self.position = 1 - def _render_student_view_for_items(self, context, display_items, fragment, view=STUDENT_VIEW): + def _render_student_view_for_blocks(self, context, children, fragment, view=STUDENT_VIEW): """ Updates the given fragment with rendered student views of the given - display_items. Returns a list of dict objects with information about - the given display_items. + children. Returns a list of dict objects with information about + the given children. """ # Avoid circular imports. from openedx.core.lib.xblock_utils import get_icon - render_items = not context.get('exclude_units', False) + render_blocks = not context.get('exclude_units', False) is_user_authenticated = self.is_user_authenticated(context) completion_service = self.runtime.service(self, 'completion') try: @@ -784,9 +784,9 @@ def _render_student_view_for_items(self, context, display_items, fragment, view= self.display_name_with_default ] contents = [] - for item in display_items: - item_type = get_icon(item) - usage_id = item.scope_ids.usage_id + for block in children: + item_type = get_icon(block) + usage_id = block.scope_ids.usage_id show_bookmark_button = False is_bookmarked = False @@ -799,10 +799,10 @@ def _render_student_view_for_items(self, context, display_items, fragment, view= context['bookmarked'] = is_bookmarked context['format'] = getattr(self, 'format', '') - if render_items: - rendered_item = item.render(view, context) - fragment.add_fragment_resources(rendered_item) - content = rendered_item.content + if render_blocks: + rendered_block = block.render(view, context) + fragment.add_fragment_resources(rendered_block) + content = rendered_block.content else: content = '' @@ -810,27 +810,27 @@ def _render_student_view_for_items(self, context, display_items, fragment, view= contains_content_type_gated_content = False if content_type_gating_service: contains_content_type_gated_content = content_type_gating_service.check_children_for_content_type_gating_paywall( # pylint:disable=line-too-long - item, self.scope_ids.usage_id.context_key + block, self.scope_ids.usage_id.context_key ) is not None - iteminfo = { + block_info = { 'content': content, - 'page_title': getattr(item, 'tooltip_title', ''), + 'page_title': getattr(block, 'tooltip_title', ''), 'type': item_type, 'id': str(usage_id), 'bookmarked': is_bookmarked, - 'path': " > ".join(display_names + [item.display_name_with_default]), - 'graded': item.graded, + 'path': " > ".join(display_names + [block.display_name_with_default]), + 'graded': block.graded, 'contains_content_type_gated_content': contains_content_type_gated_content, } - if not render_items: + if not render_blocks: # The item url format can be defined in the template context like so: # context['item_url'] = '/my/item/path/{usage_key}/whatever' - iteminfo['href'] = context.get('item_url', '').format(usage_key=usage_id) + block_info['href'] = context.get('item_url', '').format(usage_key=usage_id) if is_user_authenticated: - if item.location.block_type == 'vertical' and completion_service: - iteminfo['complete'] = completion_service.vertical_is_complete(item) + if block.location.block_type == 'vertical' and completion_service: + block_info['complete'] = completion_service.vertical_is_complete(block) - contents.append(iteminfo) + contents.append(block_info) return contents @@ -862,7 +862,7 @@ def _capture_basic_metrics(self): newrelic.agent.add_custom_parameter('seq.position', self.position) newrelic.agent.add_custom_parameter('seq.is_time_limited', self.is_time_limited) - def _capture_full_seq_item_metrics(self, display_items): + def _capture_full_seq_item_metrics(self, children): """ Capture information about the number and types of XBlock content in the sequence as a whole. We send this information to New Relic so that @@ -872,7 +872,7 @@ def _capture_full_seq_item_metrics(self, display_items): return # Basic count of the number of Units (a.k.a. VerticalBlocks) we have in # this learning sequence - newrelic.agent.add_custom_parameter('seq.num_units', len(display_items)) + newrelic.agent.add_custom_parameter('seq.num_units', len(children)) # Count of all modules (leaf nodes) in this sequence (e.g. videos, # problems, etc.) The units (verticals) themselves are not counted. @@ -884,7 +884,7 @@ def _capture_full_seq_item_metrics(self, display_items): for block_type, count in block_counts.items(): newrelic.agent.add_custom_parameter(f'seq.block_counts.{block_type}', count) - def _capture_current_unit_metrics(self, display_items): + def _capture_current_unit_metrics(self, children): """ Capture information about the current selected Unit within the Sequence. """ @@ -893,13 +893,13 @@ def _capture_current_unit_metrics(self, display_items): # Positions are stored with indexing starting at 1. If we get into a # weird state where the saved position is out of bounds (e.g. the # content was changed), avoid going into any details about this unit. - if 1 <= self.position <= len(display_items): + if 1 <= self.position <= len(children): # Basic info about the Unit... - current = display_items[self.position - 1] + current = children[self.position - 1] newrelic.agent.add_custom_parameter('seq.current.block_id', str(current.location)) newrelic.agent.add_custom_parameter('seq.current.display_name', current.display_name or '') - # Examining all items inside the Unit (or split_test, conditional, etc.) + # Examining all blocks inside the Unit (or split_test, conditional, etc.) child_locs = self._locations_in_subtree(current) newrelic.agent.add_custom_parameter('seq.current.num_items', len(child_locs)) curr_block_counts = collections.Counter(usage_key.block_type for usage_key in child_locs) diff --git a/xmodule/template_block.py b/xmodule/template_block.py index 2d2d6a531364..2c542ba4fcdd 100644 --- a/xmodule/template_block.py +++ b/xmodule/template_block.py @@ -111,7 +111,7 @@ def render_template(self, system, xml_data): # cdodge: look up the template as a module template_loc = self.location.replace(category='custom_tag_template', name=template_name) - template_block = system.load_item(template_loc) + template_block = system.get_block(template_loc) template_block_data = template_block.data template = Template(template_block_data) return template.safe_substitute(params) diff --git a/xmodule/tests/test_conditional.py b/xmodule/tests/test_conditional.py index c8a59efb4ec2..8f63150a9262 100644 --- a/xmodule/tests/test_conditional.py +++ b/xmodule/tests/test_conditional.py @@ -91,7 +91,6 @@ def create(system, source_is_error_module=False, source_visible_to_staff_only=Fa child_descriptor.visible_to_staff_only = False child_descriptor._xmodule.student_view.return_value = Fragment(content='
This is a secret
') # lint-amnesty, pylint: disable=protected-access child_descriptor.student_view = child_descriptor._xmodule.student_view # lint-amnesty, pylint: disable=protected-access - child_descriptor.displayable_items.return_value = [child_descriptor] child_descriptor.runtime = descriptor_system child_descriptor.xmodule_runtime = get_test_system() child_descriptor.render = lambda view, context=None: descriptor_system.render(child_descriptor, view, context) diff --git a/xmodule/tests/test_library_root.py b/xmodule/tests/test_library_root.py index 0d194d11690c..0390aaa7ccce 100644 --- a/xmodule/tests/test_library_root.py +++ b/xmodule/tests/test_library_root.py @@ -7,7 +7,7 @@ from web_fragments.fragment import Fragment from xblock.runtime import Runtime as VanillaRuntime -from xmodule.modulestore.tests.factories import ItemFactory, LibraryFactory +from xmodule.modulestore.tests.factories import BlockFactory, LibraryFactory from xmodule.modulestore.tests.utils import MixedSplitTestCase from xmodule.x_module import AUTHOR_VIEW @@ -35,7 +35,7 @@ def test_library_author_view(self): message = "Hello world" library = LibraryFactory.create(modulestore=self.store) # Add one HTML block to the library: - ItemFactory.create( + BlockFactory.create( category="html", parent_location=library.location, user_id=self.user_id, @@ -60,7 +60,7 @@ def test_library_author_view_with_paging(self): library = LibraryFactory.create(modulestore=self.store) # Add five HTML blocks to the library: blocks = [ - ItemFactory.create( + BlockFactory.create( category="html", parent_location=library.location, user_id=self.user_id, diff --git a/xmodule/tests/test_library_sourced_block.py b/xmodule/tests/test_library_sourced_block.py index 246a6fa05a94..12acc31d943d 100644 --- a/xmodule/tests/test_library_sourced_block.py +++ b/xmodule/tests/test_library_sourced_block.py @@ -5,7 +5,7 @@ from openedx.core.djangoapps.content_libraries.tests.base import ContentLibrariesRestApiTest from common.djangoapps.student.roles import CourseInstructorRole from xmodule.modulestore.django import modulestore -from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory +from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory from xmodule.tests import get_test_system from xmodule.x_module import STUDENT_VIEW # lint-amnesty, pylint: disable=unused-import @@ -21,7 +21,7 @@ def setUp(self): course = CourseFactory.create(modulestore=self.store, user_id=self.user.id) CourseInstructorRole(course.id).add_users(self.user) # Add a "Source from Library" block to the course - self.source_block = ItemFactory.create( + self.source_block = BlockFactory.create( category="library_sourced", parent=course, parent_location=course.location, diff --git a/xmodule/tests/test_video.py b/xmodule/tests/test_video.py index fa19b18b67ff..c21be47b568d 100644 --- a/xmodule/tests/test_video.py +++ b/xmodule/tests/test_video.py @@ -7,7 +7,7 @@ search for usages of this in the cms and lms tests for examples. You use this so that it will do things like point the modulestore setting to mongo, flush the contentstore before and after, load the templates, etc. -You can then use the CourseFactory and XModuleItemFactory as defined +You can then use the CourseFactory and BlockFactory as defined in xmodule/modulestore/tests/factories.py to create the course, section, subsection, unit, etc. """ diff --git a/xmodule/vertical_block.py b/xmodule/vertical_block.py index b800d549f6ae..9ebe3a4e2b0b 100644 --- a/xmodule/vertical_block.py +++ b/xmodule/vertical_block.py @@ -95,7 +95,7 @@ def _student_or_public_view(self, context, view): 'edx-platform.username' ) - child_blocks = self.get_display_items() # lint-amnesty, pylint: disable=no-member + child_blocks = self.get_children() # lint-amnesty, pylint: disable=no-member child_blocks_to_complete_on_view = set() completion_service = self.runtime.service(self, 'completion') diff --git a/xmodule/x_module.py b/xmodule/x_module.py index a011e612853b..81fe6429dcb6 100644 --- a/xmodule/x_module.py +++ b/xmodule/x_module.py @@ -524,24 +524,6 @@ def get_required_module_descriptors(self): not children of this module""" return [] - def get_display_items(self): - """ - Returns a list of descendent module instances that will display - immediately inside this module. - """ - items = [] - for child in self.get_children(): - items.extend(child.displayable_items()) - - return items - - def displayable_items(self): - """ - Returns list of displayable modules contained by this module. If this - module is visible, should return [self]. - """ - return [self] - def get_child_by(self, selector): """ Return a child XBlock that matches the specified selector