refactor: rename ItemFactory to BlockFactory

This commit is contained in:
Arunmozhi
2022-12-01 11:15:04 +05:30
committed by Agrendalath
parent 4a41208cf9
commit d417a7561f
145 changed files with 1351 additions and 1348 deletions

View File

@@ -12,7 +12,7 @@ from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.course_api.blocks.transformers.block_completion import BlockCompletionTransformer
from lms.djangoapps.course_blocks.api import get_course_blocks
from lms.djangoapps.course_blocks.transformers.tests.helpers import ModuleStoreTestCase, TransformerRegistryTestMixin
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 StubAggregatorXBlock(XBlock):
@@ -66,14 +66,14 @@ class BlockCompletionTransformerTestCase(TransformerRegistryTestMixin, Completio
"""
course = CourseFactory.create()
# Have to have at least one complete block to trigger entering the marking 'complete' flow
filled_aggregator = ItemFactory.create(category='aggregator', parent=course)
block = ItemFactory.create(category='comp', parent=filled_aggregator)
filled_aggregator = BlockFactory.create(category='aggregator', parent=course)
block = BlockFactory.create(category='comp', parent=filled_aggregator)
BlockCompletion.objects.submit_completion(
user=self.user,
block_key=block.location,
completion=self.COMPLETION_TEST_VALUE,
)
empty_aggregator = ItemFactory.create(category='aggregator', parent=course)
empty_aggregator = BlockFactory.create(category='aggregator', parent=course)
block_structure = get_course_blocks(self.user, course.location, self.transformers)
self._assert_block_has_proper_completion_values(
@@ -92,7 +92,7 @@ class BlockCompletionTransformerTestCase(TransformerRegistryTestMixin, Completio
Excluded blocks always receive None for 'completion' and False for 'complete'
"""
course = CourseFactory.create()
block = ItemFactory.create(category='excluded', parent=course)
block = BlockFactory.create(category='excluded', parent=course)
block_structure = get_course_blocks(self.user, course.location, self.transformers)
self._assert_block_has_proper_completion_values(block_structure, block.location, None, False)
@@ -104,7 +104,7 @@ class BlockCompletionTransformerTestCase(TransformerRegistryTestMixin, Completio
'completion' should have the value and 'complete' should be True in these cases.
"""
course = CourseFactory.create()
block = ItemFactory.create(category='comp', parent=course)
block = BlockFactory.create(category='comp', parent=course)
BlockCompletion.objects.submit_completion(
user=self.user,
block_key=block.location,
@@ -122,7 +122,7 @@ class BlockCompletionTransformerTestCase(TransformerRegistryTestMixin, Completio
'html' blocks end up receiving a 'completion' of 1.0 after being viewed.
"""
course = CourseFactory.create()
block = ItemFactory.create(category='html', parent=course)
block = BlockFactory.create(category='html', parent=course)
block_structure = get_course_blocks(self.user, course.location, self.transformers)
self._assert_block_has_proper_completion_values(block_structure, block.location, 0.0, False)

View File

@@ -18,7 +18,7 @@ from rest_framework.test import APIRequestFactory
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from xmodule.modulestore.exceptions import ItemNotFoundError # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import ItemFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import BlockFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order
from ..api import (
UNKNOWN_BLOCK_DISPLAY_NAME, course_detail, get_due_dates, list_courses, get_course_members, get_course_run_url,
@@ -287,7 +287,7 @@ class TestGetCourseDates(CourseDetailTestMixin, SharedModuleStoreTestCase):
cls.yesterday = cls.today - timedelta(days=1)
cls.tomorrow = cls.today + timedelta(days=1)
cls.section_1 = ItemFactory.create(
cls.section_1 = BlockFactory.create(
category='chapter',
start=cls.yesterday,
due=cls.tomorrow,
@@ -295,7 +295,7 @@ class TestGetCourseDates(CourseDetailTestMixin, SharedModuleStoreTestCase):
display_name='section 1'
)
cls.subsection_1 = ItemFactory.create(
cls.subsection_1 = BlockFactory.create(
category='sequential',
parent=cls.section_1,
display_name='subsection 1'