#!/usr/bin/env python3 """Unit check for the mandatory lab5 thumbnail conversion.""" import io from pathlib import Path from PIL import Image from app.worker import _make_thumbnail ROOT = Path(__file__).resolve().parents[1] source = (ROOT / 'tests' / 'fixtures' / 'sample.png').read_bytes() content, width, height = _make_thumbnail(source) with Image.open(io.BytesIO(content)) as thumbnail: assert thumbnail.format == 'JPEG' assert thumbnail.size == (256, 160) assert (width, height) == (256, 160) print('PASS: 320x200 PNG produces a real JPEG thumbnail of 256x160')