Skip to content

Commit

Permalink
Convert CaptureOne TIFF to Digital Library Compound Object and HathiT…
Browse files Browse the repository at this point in the history
…rust raises error if no packages are found
  • Loading branch information
henryborchers committed Dec 13, 2023
1 parent 276fb4f commit 7f2806a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions tests/workflows/test_capture_one_to_dl_compound_and_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 7f2806a

Please sign in to comment.