@@ -2545,6 +2545,7 @@ def test_publish_functions_rejected_inside_bulk_draft_changes_for(self) -> None:
25452545 ordering of DraftChangeLog vs. PublishLog records and can leave Drafts
25462546 and Published rows out of sync if the outer context later raises.
25472547 """
2548+ lp1_id = self .learning_package_1 .id
25482549 entity = publishing_api .create_publishable_entity (
25492550 self .learning_package_1 .id ,
25502551 "entity_for_bulk_publish_check" ,
@@ -2559,13 +2560,20 @@ def test_publish_functions_rejected_inside_bulk_draft_changes_for(self) -> None:
25592560 created_by = None ,
25602561 )
25612562
2562- with pytest .raises (ValidationError , match = "Cannot publish while in bulk_draft_changes_for()." ):
2563- with publishing_api .bulk_draft_changes_for (self .learning_package_1 .id ):
2564- publishing_api .publish_all_drafts (self .learning_package_1 .id )
2563+ with pytest .raises (
2564+ ValidationError ,
2565+ match = f"Cannot publish learning package { lp1_id } while in bulk_draft_changes_for()."
2566+ ):
2567+ with publishing_api .bulk_draft_changes_for (lp1_id ):
2568+ publishing_api .publish_all_drafts (lp1_id )
25652569
2566- with pytest .raises (ValidationError , match = "Cannot publish while in bulk_draft_changes_for()." ):
2567- with publishing_api .bulk_draft_changes_for (self .learning_package_1 .id ):
2568- publishing_api .publish_from_drafts (
2569- self .learning_package_1 .id ,
2570- Draft .objects .filter (entity__learning_package_id = self .learning_package_1 .id ),
2571- )
2570+ with pytest .raises (
2571+ ValidationError ,
2572+ match = f"Cannot publish learning package { lp1_id } while in bulk_draft_changes_for()."
2573+ ):
2574+ with publishing_api .bulk_draft_changes_for (lp1_id ):
2575+ publishing_api .publish_from_drafts (lp1_id , Draft .objects .filter (entity__learning_package_id = lp1_id ))
2576+
2577+ # But we CAN publish if the bulk_draft_changes_for is a different learning package:
2578+ with publishing_api .bulk_draft_changes_for (self .learning_package_2 .id ):
2579+ publishing_api .publish_all_drafts (lp1_id )
0 commit comments