refactor: rename ItemFactory to BlockFactory
This commit is contained in:
@@ -9,7 +9,7 @@ from django.views.decorators.csrf import csrf_exempt
|
||||
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 @@ class ProviderState(ModuleStoreIsolationMixin):
|
||||
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'
|
||||
),
|
||||
|
||||
@@ -18,7 +18,7 @@ from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
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 @@ class BaseCoursewareTests(SharedModuleStoreTestCase):
|
||||
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 @@ class SequenceApiTestViews(MasqueradeMixin, BaseCoursewareTests):
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user