Skip to content

Commit

Permalink
Revert "Update api/test/unit/views/test_image_views.py"
Browse files Browse the repository at this point in the history
This reverts commit 11518b6.
  • Loading branch information
obulat committed Oct 25, 2023
1 parent 11518b6 commit 16c920e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions api/test/unit/views/test_image_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ def test_thumbnail_uses_upstream_thumb_for_smk(
@pytest.mark.django_db
def test_watermark_raises_424_for_invalid_image(api_client):
image = ImageFactory.create()
with patch(
"PIL.Image.open", side_effect=UnidentifiedImageError("bad image")
), pytest.raises(UpstreamWatermarkException):
expected_error_message = (
"cannot identify image file <_io.BytesIO object at 0xffff86d8fec0>"
)

with patch("PIL.Image.open") as mock_open:
mock_open.side_effect = UnidentifiedImageError(expected_error_message)
res = api_client.get(f"/v1/images/{image.identifier}/watermark/")
assert res.status_code == 424
assert res.data["detail"] == expected_error_message


@pytest.mark.django_db
Expand Down

0 comments on commit 16c920e

Please sign in to comment.