diff --git a/openedx/core/djangoapps/content/block_structure/tests/helpers.py b/openedx/core/djangoapps/content/block_structure/tests/helpers.py index 93655c79e16e..84c99d71e1f0 100644 --- a/openedx/core/djangoapps/content/block_structure/tests/helpers.py +++ b/openedx/core/djangoapps/content/block_structure/tests/helpers.py @@ -7,6 +7,7 @@ from uuid import uuid4 from unittest.mock import patch +from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator from xmodule.modulestore.exceptions import ItemNotFoundError @@ -264,7 +265,7 @@ def block_key_factory(self, block_id): Override this method if the block_key should be anything different from the index integer values in the Children Maps. """ - return block_id + return CourseKey.from_string("course-v1:org+course+run").make_usage_key("html", str(block_id)) def create_block_structure(self, children_map, block_structure_cls=BlockStructureBlockData): """ @@ -274,10 +275,12 @@ def create_block_structure(self, children_map, block_structure_cls=BlockStructur # create empty block structure block_structure = block_structure_cls(root_block_usage_key=self.block_key_factory(0)) - # _add_relation + # _add_relation and blocks for parent, children in enumerate(children_map): + block_structure._get_or_create_block(self.block_key_factory(parent)) for child in children: block_structure._add_relation(self.block_key_factory(parent), self.block_key_factory(child)) # pylint: disable=protected-access + block_structure._get_or_create_block(self.block_key_factory(child)) return block_structure def get_parents_map(self, children_map):