Skip to content

Commit 46ed508

Browse files
committed
Expect BadImageError on corrupted image
1 parent 0ee953e commit 46ed508

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

tests/mock_vws/test_add_target.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,21 @@ def test_corrupted(
478478
vws_client: VWS,
479479
) -> None:
480480
"""
481-
No error is returned when the given image is corrupted.
481+
An error is returned when the given image is corrupted.
482482
"""
483-
vws_client.add_target(
484-
name="example_name",
485-
width=1,
486-
image=corrupted_image_file,
487-
application_metadata=None,
488-
active_flag=True,
483+
with pytest.raises(expected_exception=BadImageError) as exc:
484+
vws_client.add_target(
485+
name="example_name",
486+
width=1,
487+
image=corrupted_image_file,
488+
application_metadata=None,
489+
active_flag=True,
490+
)
491+
492+
assert_vws_failure(
493+
response=exc.value.response,
494+
status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
495+
result_code=ResultCodes.BAD_IMAGE,
489496
)
490497

491498
@staticmethod

tests/mock_vws/test_get_target.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ def test_target_quality(
146146
vws_client: VWS,
147147
high_quality_image: io.BytesIO,
148148
image_file_success_state_low_rating: io.BytesIO,
149-
corrupted_image_file: io.BytesIO,
150149
) -> None:
151150
"""
152151
The target tracking rating is as expected.
@@ -159,14 +158,9 @@ def test_target_quality(
159158
vws_client=vws_client,
160159
image_file=image_file_success_state_low_rating,
161160
)
162-
corrupted_image_file_tracking_rating = _get_target_tracking_rating(
163-
vws_client=vws_client,
164-
image_file=corrupted_image_file,
165-
)
166161
assert (
167162
high_quality_image_tracking_rating
168163
> low_quality_image_tracking_rating
169-
>= corrupted_image_file_tracking_rating
170164
)
171165

172166

tests/mock_vws/test_update_target.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,12 +670,19 @@ def test_corrupted(
670670
target_id: str,
671671
) -> None:
672672
"""
673-
No error is returned when the given image is corrupted.
673+
An error is returned when the given image is corrupted.
674674
"""
675675
vws_client.wait_for_target_processed(target_id=target_id)
676-
vws_client.update_target(
677-
target_id=target_id,
678-
image=corrupted_image_file,
676+
with pytest.raises(expected_exception=BadImageError) as exc:
677+
vws_client.update_target(
678+
target_id=target_id,
679+
image=corrupted_image_file,
680+
)
681+
682+
assert_vws_failure(
683+
response=exc.value.response,
684+
status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
685+
result_code=ResultCodes.BAD_IMAGE,
679686
)
680687

681688
@staticmethod

0 commit comments

Comments
 (0)