feat(integrity): /api/system/stats exposes integrity counts
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -80,3 +80,28 @@ async def test_system_stats_shape(client):
|
||||
assert key in body
|
||||
for status in ("pending", "queued", "processing", "complete", "skipped", "failed"):
|
||||
assert status in body["tasks"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_system_stats_integrity_counts(client, db):
|
||||
from backend.app.models import ImageRecord
|
||||
|
||||
base = "stats_" + "0" * 56
|
||||
for i, status in enumerate(
|
||||
["ok", "ok", "corrupt", "failed_verification"]
|
||||
):
|
||||
db.add(ImageRecord(
|
||||
path=f"/images/i/{i}.jpg", sha256=base + f"{i:02d}",
|
||||
size_bytes=1, mime="image/jpeg", width=1, height=1,
|
||||
origin="imported_filesystem", integrity_status=status,
|
||||
))
|
||||
await db.commit()
|
||||
|
||||
resp = await client.get("/api/system/stats")
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
integ = body["integrity"]
|
||||
assert integ["ok"] >= 2
|
||||
assert integ["corrupt"] >= 1
|
||||
assert integ["failed_verification"] >= 1
|
||||
assert "unknown" in integ
|
||||
|
||||
Reference in New Issue
Block a user