@@ -587,6 +587,51 @@ def test_add_dicom_image_set_to_object_marks_job_as_failed_on_validation_fail(
587587 assert "some_async_task" not in str (callbacks )
588588
589589
590+ @pytest .mark .parametrize (
591+ "object_type" ,
592+ [
593+ DisplaySetFactory ,
594+ ArchiveItemFactory ,
595+ ],
596+ )
597+ @pytest .mark .django_db
598+ def test_add_dicom_image_set_to_object_sends_notification_on_validation_fail (
599+ settings ,
600+ django_capture_on_commit_callbacks ,
601+ object_type ,
602+ ):
603+ settings .task_eager_propagates = (True ,)
604+ settings .task_always_eager = (True ,)
605+
606+ obj = object_type ()
607+ # create upload without resulting dicom image set and image.
608+ upload = DICOMImageSetUploadFactory (
609+ status = DICOMImageSetUploadStatusChoices .COMPLETED
610+ )
611+ ci = ComponentInterfaceFactory (kind = InterfaceKindChoices .DICOM_IMAGE_SET )
612+ linked_task = some_async_task .signature (
613+ kwargs = {"foo" : "bar" }, immutable = True
614+ )
615+
616+ with django_capture_on_commit_callbacks (execute = True ) as callbacks :
617+ add_dicom_image_set_to_object (
618+ app_label = obj ._meta .app_label ,
619+ model_name = obj ._meta .model_name ,
620+ object_pk = obj .pk ,
621+ interface_pk = ci .pk ,
622+ dicom_image_set_upload_pk = upload .pk ,
623+ linked_task = linked_task ,
624+ )
625+
626+ assert ComponentInterfaceValue .objects .filter (interface = ci ).count () == 0
627+ assert Notification .objects .count () == 1
628+ assert (
629+ f"Validation for socket { ci .title } failed."
630+ in Notification .objects .first ().message
631+ )
632+ assert "some_async_task" not in str (callbacks )
633+
634+
590635@pytest .mark .parametrize (
591636 "task, task_extra_kwargs" ,
592637 (
0 commit comments