926d0fa272
Tests / test (push) Failing after 0s
Tests / lint (push) Failing after 0s
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
Deploy / Deploy Staging (push) Has been cancelled
Deploy / Build Production Runtime Images (push) Has been cancelled
Deploy / Deploy Production (push) Has been cancelled
Deploy / Production Browser E2E (push) Has been cancelled
45 lines
1.2 KiB
Python
45 lines
1.2 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(
|
|
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),
|
|
]
|
|
)
|