Skip to content

Commit a5bcc11

Browse files
committed
refactor: ContentLibraryContainersTest to use update_container_children to add components
1 parent 6c12709 commit a5bcc11

2 files changed

Lines changed: 13 additions & 28 deletions

File tree

openedx/core/djangoapps/content_libraries/api/containers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class ContainerMetadata(PublishableItem):
6060
Class that represents the metadata about a Container (e.g. Unit) in a content library.
6161
"""
6262
container_key: LibraryContainerLocator
63-
container_pk: int
6463
container_type: ContainerType
6564

6665
@classmethod
@@ -89,7 +88,6 @@ def from_container(cls, library_key, container: Container, associated_collection
8988

9089
return cls(
9190
container_key=container_key, # LibraryContainerLocator
92-
container_pk=container.pk, # authoring_models.Container.pk
9391
container_type=container_type,
9492
display_name=draft.title,
9593
created=container.created,

openedx/core/djangoapps/content_libraries/tests/test_api.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -766,38 +766,25 @@ def setUp(self):
766766

767767
# Create XBlocks
768768
# Create some library blocks in lib1
769-
self.problem_block_dict = self._add_block_to_library(
769+
self.problem_block = self._add_block_to_library(
770770
self.lib1.library_key, "problem", "problem1",
771771
)
772-
self.problem_block_usage_key = UsageKey.from_string(self.problem_block_dict["id"])
773-
self.html_block_dict = self._add_block_to_library(
772+
self.problem_block_usage_key = UsageKey.from_string(self.problem_block["id"])
773+
self.html_block = self._add_block_to_library(
774774
self.lib1.library_key, "html", "html1",
775775
)
776-
self.html_block_usage_key = UsageKey.from_string(self.html_block_dict["id"])
777-
now = datetime.now(tz=timezone.utc)
776+
self.html_block_usage_key = UsageKey.from_string(self.html_block["id"])
778777

779778
# Add content to units
780-
# TODO build API for this
781-
self.problem_block_component = api.get_component_from_usage_key(self.problem_block_usage_key)
782-
self.html_block_component = api.get_component_from_usage_key(self.html_block_usage_key)
783-
authoring_api.create_next_container_version(
784-
self.unit1.container_pk,
785-
publishable_entities_pks=[
786-
self.problem_block_component.publishable_entity.id,
787-
self.html_block_component.publishable_entity.id,
788-
],
789-
title=None,
790-
entity_version_pks=None,
791-
created=now,
792-
created_by=None,
793-
)
794-
authoring_api.create_next_container_version(
795-
self.unit2.container_pk,
796-
publishable_entities_pks=[self.html_block_component.publishable_entity.id],
797-
title=None,
798-
entity_version_pks=None,
799-
created=now,
800-
created_by=None,
779+
api.update_container_children(
780+
self.unit1.container_key,
781+
[self.problem_block_usage_key, self.html_block_usage_key],
782+
None,
783+
)
784+
api.update_container_children(
785+
self.unit2.container_key,
786+
[self.html_block_usage_key],
787+
None,
801788
)
802789

803790
def test_get_containers_contains_component(self):

0 commit comments

Comments
 (0)