feat(post-api): get_post returns uncapped thumbnails — PostModal masonry needs full image list; feed query unchanged (still capped at 6 for previews). _thumbnails_for gains a limit kwarg; get_post passes limit=None.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -117,3 +117,50 @@ async def test_detail_404_for_unknown(client):
|
||||
assert resp.status_code == 404
|
||||
body = await resp.get_json()
|
||||
assert body["error"] == "not_found"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_detail_returns_uncapped_thumbnails(client, db):
|
||||
"""Feed query caps thumbnails at 6 for previews; detail endpoint
|
||||
returns the full list so PostModal can render the masonry grid."""
|
||||
from backend.app.models import ImageRecord
|
||||
|
||||
a = Artist(name="yuki-api", slug="yuki-api")
|
||||
db.add(a)
|
||||
await db.flush()
|
||||
s = Source(
|
||||
artist_id=a.id, platform="patreon",
|
||||
url="https://patreon.com/cw/yuki-api", enabled=True,
|
||||
)
|
||||
db.add(s)
|
||||
await db.flush()
|
||||
p = Post(
|
||||
source_id=s.id, external_post_id="DETAIL10",
|
||||
post_title="big post", description="<p>body</p>",
|
||||
)
|
||||
db.add(p)
|
||||
await db.flush()
|
||||
# Seed 10 ImageRecord rows linked to this post via primary_post_id.
|
||||
for i in range(10):
|
||||
sha = f"y{i:x}".ljust(64, "0")[:64]
|
||||
rec = ImageRecord(
|
||||
path=f"/images/test-yuki-{i}.jpg",
|
||||
sha256=sha,
|
||||
size_bytes=1,
|
||||
mime="image/jpeg",
|
||||
width=64,
|
||||
height=64,
|
||||
origin="downloaded",
|
||||
integrity_status="unknown",
|
||||
primary_post_id=p.id,
|
||||
artist_id=a.id,
|
||||
)
|
||||
db.add(rec)
|
||||
await db.commit()
|
||||
|
||||
resp = await client.get(f"/api/posts/{p.id}")
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
# Detail returns ALL 10 thumbnails (feed would return 6 + thumbnails_more).
|
||||
assert len(body["thumbnails"]) == 10
|
||||
assert body["description_full"] == "body"
|
||||
|
||||
Reference in New Issue
Block a user