File tree Expand file tree Collapse file tree
tests/openedx_learning/apps/authoring/units Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments