Files
xiaoxia-saas/tests/unit/test_generation_preflight.py
T
Xiaoxia AI 6e00c9d3c3
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 18s
Deploy / Deploy Staging (push) Successful in 1s
style: sort Python imports for CI
2026-06-24 19:57:19 +08:00

46 lines
1.3 KiB
Python

import sys
from pathlib import Path
import pytest
from fastapi import HTTPException
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "apps" / "api"))
from app.api.routes.generation_tasks import _ensure_library_has_ready_video_assets
from packages.domain import Asset, AssetStatus
def _asset(name: str, mime_type: str, status: AssetStatus) -> Asset:
return Asset.create(
workspace_id="workspace-1",
project_id="project-1",
library_id="library-1",
name=name,
storage_key=f"uploads/{name}",
mime_type=mime_type,
file_size=1024,
status=status,
)
def test_generation_preflight_rejects_library_without_ready_video():
with pytest.raises(HTTPException) as exc_info:
_ensure_library_has_ready_video_assets(
[
_asset("image.jpg", "image/jpeg", AssetStatus.READY),
_asset("video.mp4", "video/mp4", AssetStatus.UPLOADING),
]
)
assert exc_info.value.status_code == 422
assert "ready 状态的视频素材" in exc_info.value.detail
def test_generation_preflight_accepts_ready_video():
_ensure_library_has_ready_video_assets(
[
_asset("video.mp4", "video/mp4", AssetStatus.READY),
]
)