Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for JHOVE module validation #216

Merged
merged 9 commits into from
Feb 26, 2025
32 changes: 16 additions & 16 deletions features/black_box/validation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ Feature: Alma wants to ensure that JHOVE validation in Archivematica works corre
And 8 "Validate formats" transfer tasks failed
And 9 "Validate formats" transfer tasks succeeded
And the "Validation" microservice is executed
And 1 AIFF file is failed
And 1 AIFF file is succeeded
And 1 GIF file is failed
And 1 GIF file is succeeded
And 1 JP2 file is failed
And 1 JP2 file is succeeded
And 1 JPG file is failed
And 1 JPG file is succeeded
And 1 PDF file is failed
And 1 PDF file is succeeded
And 1 TIF file is failed
And 1 TIF file is succeeded
And 1 WARC file is failed
And 1 WARC file is succeeded
And 1 WAV file is failed
And 1 WAV file is succeeded
And 1 AIFF file(s) failed
And 1 AIFF file(s) succeeded
And 1 GIF file(s) failed
And 1 GIF file(s) succeeded
And 1 JP2 file(s) failed
And 1 JP2 file(s) succeeded
And 1 JPG file(s) failed
And 1 JPG file(s) succeeded
And 1 PDF file(s) failed
And 1 PDF file(s) succeeded
And 1 TIF file(s) failed
And 1 TIF file(s) succeeded
And 1 WARC file(s) failed
And 1 WARC file(s) succeeded
And 1 WAV file(s) failed
And 1 WAV file(s) succeeded
And the AIP can be successfully stored
And there are 16 original objects in the AIP METS with a validation event

Expand Down
28 changes: 12 additions & 16 deletions features/steps/black_box_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,9 +1545,8 @@ def step_impl(context, task_count, job_name, unit_type):
assert len(jobs), f"No jobs found for unit {unit_uuid}"
task_size = 0
for job in jobs:
for task in job["tasks"]:
if task:
task_size += 1
for _task in job["tasks"]:
task_size += 1
assert task_size == task_count, (
f"Expected {task_count} tasks to be executed for unit {unit_uuid}, got {task_size} instead."
)
Expand Down Expand Up @@ -1585,21 +1584,14 @@ def step_impl(context, task_count, job_name, unit_type):
)


def verify_task_exit_code(file_extension, task, expected_exit_codes):
if (
"." + file_extension.lower() == (pathlib.Path(task["file_name"]).suffix).lower()
and task["exit_code"] in expected_exit_codes
):
return True


@then("{file_count:d} {file_extension} file is {status}")
@then("{file_count:d} {file_extension} file(s) {status}")
def step_impl(context, file_count, file_extension, status):
unit_uuid = context.current_transfer["transfer_uuid"]
jobs = utils.get_jobs(
context.api_clients_config,
unit_uuid,
job_name="Validate formats",
job_microservice="Validation",
detailed_task=True,
)
assert len(jobs), f"No jobs found for unit {unit_uuid}"
Expand All @@ -1617,8 +1609,12 @@ def step_impl(context, file_count, file_extension, status):
total = 0
for job in jobs:
for task in job["tasks"]:
if verify_task_exit_code(file_extension, task, expected_exit_codes):
if (
"." + file_extension.lower()
== pathlib.Path(task["file_name"]).suffix.lower()
and task["exit_code"] in expected_exit_codes
):
total += 1
assert file_count == total, (
f"The expected file count for unit {unit_uuid} is {file_count}, but found {total}. "
)
assert file_count == total, (
f"The expected file count for unit {unit_uuid} is {file_count}, but found {total}. "
)