[feat] solution/backend: 발행·재발행마다 사이트 화면을 찍어 썸네일로 — 실패하면 대표 사진
썸네일이 대표 사진 한 장이라 재발행해도 쇼케이스·목록 카드가 사이트 모습과 달랐다. - site_thumbnail: Playwright(워커 이미지에 이미 있음)로 /s/<slug> 1280×800 촬영, 실패 시 대표 사진 - THUMBNAIL_CAPTURE=0 이면 촬영을 끈다 — conftest 기본값 0(테스트에서 외부 주소를 열지 않게) 테스트 2건 추가(test_site_thumbnail) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
14b6e95f9d
commit
378ad55b5b
3 files changed
+73
-7
No files matched your search
@@ -115,6 +115,39 @@ async def test_사이트_디렉터리_밖의_thumbs_에_올린다(blob, monkeypa
|
||||
|
||||
|
||||
# ── 발행 경로와의 배선 ──────────────────────────────────────────────────── 아래 두 건은 "발행이 썸네일에 매달리지 않는가" 를 본다.
|
||||
async def test_발행된_화면을_찍어_올린다(blob, monkeypatch):
|
||||
shots = []
|
||||
|
||||
async def _capture(url):
|
||||
shots.append(url)
|
||||
return b"shot", "image/jpeg", "jpg"
|
||||
|
||||
monkeypatch.setenv(site_thumbnail.CAPTURE_ENV, "1")
|
||||
monkeypatch.setattr(site_thumbnail, "_capture", _capture)
|
||||
snapshot = _snapshot({"media_id": "m1", "url": "https://cdn.test/front.jpg", "unit_id": None})
|
||||
|
||||
await site_thumbnail.store("butter", snapshot, 4)
|
||||
|
||||
from services import site_payload
|
||||
|
||||
assert shots == [f"{site_payload.publish_origin()}/s/butter"]
|
||||
assert blob.uploads[f"{azure_static.DEFAULT_PREFIX}/thumbs/butter.jpg"]["body"] == b"shot"
|
||||
|
||||
|
||||
async def test_촬영에_실패하면_대표_사진을_쓴다(blob, monkeypatch):
|
||||
async def _capture(url):
|
||||
return None
|
||||
|
||||
monkeypatch.setenv(site_thumbnail.CAPTURE_ENV, "1")
|
||||
monkeypatch.setattr(site_thumbnail, "_capture", _capture)
|
||||
_transport(monkeypatch, lambda req: httpx.Response(200, headers={"content-type": "image/jpeg"}, content=b"photo"))
|
||||
snapshot = _snapshot({"media_id": "m1", "url": "https://cdn.test/front.jpg", "unit_id": None})
|
||||
|
||||
await site_thumbnail.store("butter", snapshot, 5)
|
||||
|
||||
assert blob.uploads[f"{azure_static.DEFAULT_PREFIX}/thumbs/butter.jpg"]["body"] == b"photo"
|
||||
|
||||
|
||||
async def test_발행하면_사이트에_썸네일_주소가_남는다(auth_headers, client, db_engine, monkeypatch):
|
||||
from services import build_service
|
||||
from tests.test_build_publish import _approved_media, _place, _run, _verified_facts
|
||||
|
||||
Reference in new issue
Block a user