Implements all 88 tasks for the Reaction Image Board (specs/001-reaction-image-board): - docker-compose.yml: postgres, minio, minio-init, api, ui services with healthchecks - api/: FastAPI app with SQLAlchemy 2.x async, Alembic migrations, S3/MinIO storage, full integration + unit test suite (pytest + pytest-asyncio) - ui/: Angular 19 standalone app (Library, Upload, Detail, NotFound components) - .env.example: all required environment variables - .gitignore: Python, Node, Docker, IDE, .env patterns Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
import pytest
|
|
from app.validation import validate_mime_type, validate_file_size, MimeTypeError, FileSizeError
|
|
|
|
ACCEPTED_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"]
|
|
REJECTED_TYPES = ["application/pdf", "video/mp4", "text/plain", "application/octet-stream"]
|
|
|
|
|
|
@pytest.mark.parametrize("mime_type", ACCEPTED_TYPES)
|
|
def test_mime_type_accepts_images(mime_type):
|
|
validate_mime_type(mime_type) # should not raise
|
|
|
|
|
|
@pytest.mark.parametrize("mime_type", REJECTED_TYPES)
|
|
def test_mime_type_rejects_non_images(mime_type):
|
|
with pytest.raises(MimeTypeError):
|
|
validate_mime_type(mime_type)
|
|
|
|
|
|
def test_file_size_accepts_within_limit():
|
|
validate_file_size(1024, max_bytes=52_428_800) # should not raise
|
|
|
|
|
|
def test_file_size_accepts_exact_limit():
|
|
validate_file_size(52_428_800, max_bytes=52_428_800) # should not raise
|
|
|
|
|
|
def test_file_size_rejects_over_limit():
|
|
with pytest.raises(FileSizeError):
|
|
validate_file_size(52_428_801, max_bytes=52_428_800)
|
|
|
|
|
|
def test_file_size_rejects_zero():
|
|
with pytest.raises(FileSizeError):
|
|
validate_file_size(0, max_bytes=52_428_800)
|