Skip to content

Commit

Permalink
Add test case for Phylopic
Browse files Browse the repository at this point in the history
  • Loading branch information
krysal committed Mar 11, 2023
1 parent e020c5a commit 90456a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ collectstatic:
#########

# Run API tests inside the Docker container
test *args: _all-up
test *args:
just ../exec web ./test/run_test.sh {{ args }}

# Run API tests locally
Expand Down
15 changes: 12 additions & 3 deletions api/test/unit/views/image_views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,24 @@ def test_oembed_sends_ua_header(api_client, requests):


@pytest.mark.django_db
def test_thumbnail_uses_upstream_thumb(api_client):
@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"),
],
)
def test_thumbnail_uses_upstream_thumb(api_client, provider, expected_thumb_url):
image = ImageFactory.create(
url="http://example.com/image.jpg",
thumbnail="http://example.com/thumb.jpg",
provider="rawpixel",
provider=provider,
)
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(image.thumbnail, ANY)
thumb_call.assert_called_once_with(expected_thumb_url, ANY)

0 comments on commit 90456a1

Please sign in to comment.