"""FC-2d-iii: post_attachment table + import_batch.attachments column.""" import pytest from backend.app.models import ImportBatch, PostAttachment pytestmark = pytest.mark.integration def test_post_attachment_columns(): cols = {c.name for c in PostAttachment.__table__.columns} assert { "id", "post_id", "artist_id", "sha256", "path", "original_filename", "ext", "mime", "size_bytes", "captured_at", } <= cols def test_import_batch_has_attachments_counter(): assert "attachments" in {c.name for c in ImportBatch.__table__.columns} @pytest.mark.asyncio async def test_post_attachment_roundtrip(db): from backend.app.models import Artist a = Artist(name="Zed", slug="zed") db.add(a) await db.flush() att = PostAttachment( post_id=None, artist_id=a.id, sha256="z" + "0" * 63, path="/images/attachments/z00/z.zip", original_filename="pack.zip", ext=".zip", mime="application/zip", size_bytes=123, ) db.add(att) await db.flush() got = await db.get(PostAttachment, att.id) assert got.original_filename == "pack.zip" and got.post_id is None