Skip to content

Commit 7e127d0

Browse files
committed
test: get children component count
1 parent d2bf63d commit 7e127d0

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/openedx_learning/apps/authoring/units/test_api.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,29 @@ def test_add_remove_container_children(self):
10161016
Entry(self.component_2.versioning.draft),
10171017
]
10181018

1019+
def test_get_container_children_count(self):
1020+
"""
1021+
Test get_container_children_count()
1022+
"""
1023+
unit = self.create_unit_with_components([self.component_1])
1024+
assert authoring_api.get_container_children_count(unit.container, published=False) == 1
1025+
# publish
1026+
authoring_api.publish_all_drafts(self.learning_package.id)
1027+
unit_version = unit.versioning.draft
1028+
authoring_api.create_next_unit_version(
1029+
unit=unit,
1030+
title=unit_version.title,
1031+
components=[self.component_2],
1032+
created=self.now,
1033+
created_by=None,
1034+
entities_action=authoring_api.ChildrenEntitiesAction.APPEND,
1035+
)
1036+
unit.refresh_from_db()
1037+
# Should have two components in draft version and 1 in published version
1038+
assert authoring_api.get_container_children_count(unit.container, published=False) == 2
1039+
assert authoring_api.get_container_children_count(unit.container, published=True) == 1
1040+
1041+
10191042
# Tests TODO:
10201043
# Test that I can get a [PublishLog] history of a given unit and all its children, including children that aren't
10211044
# currently in the unit and excluding children that are only in other units.

0 commit comments

Comments
 (0)