cmvr-visual/backend/tests/test_retention.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

24 lines
946 B
Python

from datetime import timedelta
import pytest
from app.models import Asset, utcnow
from app.models import AssetReference
from app.services.retention import collect_garbage
@pytest.mark.asyncio
async def test_referenced_soft_deleted_assets_never_gc(system, png_bytes):
c = system.client
response = await c.post("/api/assets", files={"file": ("image.png", png_bytes, "image/png")})
assert response.status_code == 201
asset_id = response.json()["id"]
async with system.app.state.db.session() as session:
asset = await session.get(Asset, asset_id)
asset.deleted_at = utcnow() - timedelta(days=30)
session.add(
AssetReference(owner_id=asset.owner_id, asset_id=asset.id, ref_kind="run", ref_id="run")
)
await session.commit()
report = await collect_garbage(system.app.state.db, system.settings)
assert report["protected"] == [asset_id]
assert report["deleted"] == []