Skip to content

Commit

Permalink
Remove Phylopic exception since it's deactivated
Browse files Browse the repository at this point in the history
  • Loading branch information
krysal committed Mar 13, 2023
1 parent 90456a1 commit 25ecd38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion api/catalog/api/views/image_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def thumbnail(self, request, *_, **__):
image = self.get_object()
image_url = image.url
# TODO: Remove the Phylopic check once the thumbnails are fixed.
if image.thumbnail and image.provider != "phylopic":
if image.thumbnail:
image_url = image.thumbnail

return super().thumbnail(image_url, request)
Expand Down
18 changes: 6 additions & 12 deletions api/test/unit/views/image_views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,17 @@ def test_oembed_sends_ua_header(api_client, requests):

@pytest.mark.django_db
@pytest.mark.parametrize(
"provider, expected_thumb_url",
[
# Rawpixel is a provider with working thumbnail URLs
("rawpixel", "http://example.com/thumb.jpg"),
# Phylopic thumbnails should be omitted until fixed
("phylopic", "http://example.com/image.jpg"),
],
"has_thumbnail, expected_thumb_url",
[(True, "http://example.com/thumb.jpg"), (False, "http://example.com/image.jpg")],
)
def test_thumbnail_uses_upstream_thumb(api_client, provider, expected_thumb_url):
def test_thumbnail_uses_upstream_thumb(api_client, has_thumbnail, expected_thumb_url):
thumb_url = "http://example.com/thumb.jpg" if has_thumbnail else None
image = ImageFactory.create(
url="http://example.com/image.jpg",
thumbnail="http://example.com/thumb.jpg",
provider=provider,
thumbnail=thumb_url,
)
with patch("catalog.api.views.media_views.MediaViewSet.thumbnail") as thumb_call:
mock_response = HttpResponse("mock_response")
thumb_call.return_value = mock_response
api_client.get(f"/v1/images/{image.identifier}/thumb/")

thumb_call.assert_called_once_with(expected_thumb_url, ANY)
thumb_call.assert_called_once_with(expected_thumb_url, ANY)

0 comments on commit 25ecd38

Please sign in to comment.