From f1ad8fa91fec4ac01a2fa10d9f7cd0f40f62bea7 Mon Sep 17 00:00:00 2001 From: Olga Bulat Date: Wed, 25 Oct 2023 18:02:19 +0300 Subject: [PATCH] Revert "Update api/test/unit/views/test_image_views.py" This reverts commit 11518b6458416edfb28d7dd7bfa81bf0a1ff6bde. --- api/test/unit/views/test_image_views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/test/unit/views/test_image_views.py b/api/test/unit/views/test_image_views.py index d3192c94bc1..ffe7c0352ed 100644 --- a/api/test/unit/views/test_image_views.py +++ b/api/test/unit/views/test_image_views.py @@ -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