Skip to content

Commit

Permalink
Update api/test/unit/views/test_image_views.py
Browse files Browse the repository at this point in the history
Co-authored-by: Krystle Salazar <github@krysal.co>
  • Loading branch information
obulat and krysal authored Oct 21, 2023
1 parent 5d7b3bb commit 11518b6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions api/test/unit/views/test_image_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,11 @@ 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()
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)
with patch(
"PIL.Image.open", side_effect=UnidentifiedImageError("bad image")
), pytest.raises(UpstreamWatermarkException):
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 11518b6

Please sign in to comment.