@@ -449,6 +449,53 @@ def test_publish_container(self) -> None:
449449 c2_after = self ._get_container (container2 ["id" ])
450450 assert c2_after ["has_unpublished_changes" ]
451451
452+ def test_publish_child_container (self ):
453+ """
454+ Test the events that get emitted when we publish the changes to a container that is child of another container
455+ """
456+ # Create some containers
457+ unit = self ._create_container (self .lib1_key , "unit" , display_name = "Alpha Unit" , slug = None )
458+ subsection = self ._create_container (self .lib1_key , "subsection" , display_name = "Bravo Subsection" , slug = None )
459+
460+ # Add one container as child
461+ self ._add_container_children (subsection ["id" ], children_ids = [unit ["id" ]])
462+
463+ # At first everything is unpublished:
464+ c1_before = self ._get_container (unit ["id" ])
465+ assert c1_before ["has_unpublished_changes" ]
466+ c2_before = self ._get_container (subsection ["id" ])
467+ assert c2_before ["has_unpublished_changes" ]
468+
469+ # clear event log after the initial mock data setup is complete:
470+ self .clear_events ()
471+
472+ # Now publish only the unit
473+ self ._publish_container (unit ["id" ])
474+
475+ # Now it is published:
476+ c1_after = self ._get_container (unit ["id" ])
477+ assert c1_after ["has_unpublished_changes" ] is False
478+
479+ # And publish events were emitted:
480+ self .expect_new_events (
481+ { # An event for the unit being published:
482+ "signal" : LIBRARY_CONTAINER_PUBLISHED ,
483+ "library_container" : LibraryContainerData (
484+ container_key = LibraryContainerLocator .from_string (unit ["id" ]),
485+ ),
486+ },
487+ { # An event for parent (subsection):
488+ "signal" : LIBRARY_CONTAINER_PUBLISHED ,
489+ "library_container" : LibraryContainerData (
490+ container_key = LibraryContainerLocator .from_string (subsection ["id" ]),
491+ ),
492+ },
493+ )
494+
495+ # note that subsection is still unpublished
496+ c2_after = self ._get_container (subsection ["id" ])
497+ assert c2_after ["has_unpublished_changes" ]
498+
452499 def test_restore_unit (self ) -> None :
453500 """
454501 Test restoring a deleted unit via the "restore" API.
0 commit comments