Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Use upstream thumbnail if available #1138

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Trying a test
  • Loading branch information
Krystle Salazar committed Feb 10, 2023
commit 7177fafd790c9bee19f61dbd8ed6c4a39acf35c0
13 changes: 13 additions & 0 deletions api/test/unit/views/image_views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import dataclass
from pathlib import Path
from test.factory.models.image import ImageFactory
from unittest.mock import patch

import pytest
from requests import Request, Response
Expand Down Expand Up @@ -56,3 +57,15 @@ def test_oembed_sends_ua_header(api_client, requests):
assert len(requests.requests) > 0
for r in requests.requests:
assert r.headers == ImageViewSet.OEMBED_HEADERS


@pytest.mark.django_db
def test_thumbnail_uses_upstream_thumb(api_client):
image = ImageFactory.create()
with patch("catalog.api.views.media_views.photon.get") as photon_patch:
api_client.get(f"/v1/images/{image.identifier}/thumbnail/")

# This is throwing "Called 0 times."
photon_patch.assert_called_once()
# A photon_patch.assert_called_once_with(image_url=image.thumbnail, ...)
# or something similar should follow after the above call passes.