diff --git a/speedwagon/workflows/workflow_capture_one_to_dl_compound_and_dl.py b/speedwagon/workflows/workflow_capture_one_to_dl_compound_and_dl.py index c18536a37..8a977431e 100644 --- a/speedwagon/workflows/workflow_capture_one_to_dl_compound_and_dl.py +++ b/speedwagon/workflows/workflow_capture_one_to_dl_compound_and_dl.py @@ -89,6 +89,9 @@ class CaptureOneToDlCompoundAndDLWorkflow(Workflow): Add EAS package format support for input + .. versionchanged:: 0.3.0 + No packages located will raise a JobCancelled error. + """ name = "Convert CaptureOne TIFF to Digital Library Compound Object and " \ @@ -188,6 +191,12 @@ def discover_task_metadata( f"Failed to locate packages at {source_input}. Reason: {error}" ) from error + if not jobs: + raise speedwagon.JobCancelled( + f"No packages located at {source_input}. Check location " + f"and/or the structure of the files and folders match the " + f"Package Type." + ) return typing.cast(List[Dict[str, typing.Union[str, Any]]], jobs) @staticmethod diff --git a/tests/workflows/test_capture_one_to_dl_compound_and_dl.py b/tests/workflows/test_capture_one_to_dl_compound_and_dl.py index af8e2ab50..0d38207f4 100644 --- a/tests/workflows/test_capture_one_to_dl_compound_and_dl.py +++ b/tests/workflows/test_capture_one_to_dl_compound_and_dl.py @@ -555,3 +555,30 @@ def test_tasks_have_description(): package_format="HathiTrust jp2" ) assert task.task_description() is not None + + +class TestCaptureOneToDlCompoundAndDLWorkflow: + def test_finding_no_jobs_raises_job_cancel_exception(self, monkeypatch): + workflow = ht_wf.CaptureOneToDlCompoundAndDLWorkflow() + PackageFactory = Mock( + spec_set=packager.PackageFactory, + locate_packages=lambda *_: [] + ) + monkeypatch.setattr( + ht_wf.packager, + "PackageFactory", + lambda *_: PackageFactory + ) + with pytest.raises(speedwagon.JobCancelled) as e: + workflow.discover_task_metadata( + [], + additional_data={}, + **{ + "Input": "somepath", + "Output Digital Library": None, + "Output HathiTrust": "someoutpath", + "Package Type": "Archival collections/Non EAS" + } + ) + + assert "No packages located" in str(e)