feat(attachments): PostAttachment model + 0009 (table + batch counter)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 11:10:53 -04:00
parent e3f6e6fadd
commit 8f69478227
5 changed files with 155 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
"""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