Skip to content

Commit

Permalink
Add test for faulty existing image input
Browse files Browse the repository at this point in the history
  • Loading branch information
amickan committed Oct 16, 2024
1 parent 200d5b1 commit 9358806
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions app/tests/algorithms_tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
GPUTypeChoices,
ImportStatusChoices,
InterfaceKind,
InterfaceKindChoices,
)
from grandchallenge.subdomains.utils import reverse
from tests.algorithms_tests.factories import (
Expand Down Expand Up @@ -1439,6 +1440,47 @@ def test_create_job_with_faulty_image_input(
# and no CIVs should have been created
assert ComponentInterfaceValue.objects.count() == 0

@override_settings(task_eager_propagates=True, task_always_eager=True)
def test_create_job_with_faulty_existing_image_input(
self,
client,
django_capture_on_commit_callbacks,
algorithm_with_multiple_inputs,
):
ci = ComponentInterfaceFactory(kind=InterfaceKindChoices.SEGMENTATION)
ci.overlay_segments = [
{"name": "s1", "visible": True, "voxel_value": 1}
]
ci.save()
algorithm_with_multiple_inputs.algorithm.inputs.set([ci])

response = self.create_job(
client=client,
django_capture_on_commit_callbacks=django_capture_on_commit_callbacks,
algorithm=algorithm_with_multiple_inputs.algorithm,
user=algorithm_with_multiple_inputs.editor,
inputs={
**get_interface_form_data(
interface_slug=ci.slug,
data=algorithm_with_multiple_inputs.image_2.pk,
),
},
)
assert response.status_code == 200
assert Job.objects.count() == 1
job = Job.objects.get()
# but in cancelled state and with an error message
assert job.status == Job.CANCELLED
assert (
f"Validation for interface {ci.slug} failed." == job.error_message
)
assert (
"Image segments could not be determined, ensure the voxel values are integers and that it contains no more than 64 segments"
in str(job.detailed_error_message)
)
# and no CIVs should have been created
assert ComponentInterfaceValue.objects.count() == 0


@pytest.mark.django_db
def test_algorithm_image_activate(
Expand Down

0 comments on commit 9358806

Please sign in to comment.