7aa7f5a3d6
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
917 B
Python
36 lines
917 B
Python
"""Thumbnail backfill: _thumb_is_valid helper + backfill_thumbnails planner."""
|
|
|
|
import pytest
|
|
|
|
from backend.app.tasks.thumbnail import _thumb_is_valid
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
|
|
def test_thumb_is_valid_jpeg(tmp_path):
|
|
p = tmp_path / "good.jpg"
|
|
p.write_bytes(b"\xff\xd8\xff\xe0" + b"\x00" * 100)
|
|
assert _thumb_is_valid(p) is True
|
|
|
|
|
|
def test_thumb_is_valid_png(tmp_path):
|
|
p = tmp_path / "good.png"
|
|
p.write_bytes(b"\x89PNG\r\n\x1a\n" + b"\x00" * 100)
|
|
assert _thumb_is_valid(p) is True
|
|
|
|
|
|
def test_thumb_is_valid_too_short(tmp_path):
|
|
p = tmp_path / "tiny"
|
|
p.write_bytes(b"\xff\xd8")
|
|
assert _thumb_is_valid(p) is False
|
|
|
|
|
|
def test_thumb_is_valid_wrong_magic(tmp_path):
|
|
p = tmp_path / "garbage"
|
|
p.write_bytes(b"\x00" * 12)
|
|
assert _thumb_is_valid(p) is False
|
|
|
|
|
|
def test_thumb_is_valid_missing_file(tmp_path):
|
|
assert _thumb_is_valid(tmp_path / "nope") is False
|