e3fb518ab2
- Remove workspace_id from Pydantic models in project_management routes - Remove workspace_id from SQLAlchemy and SQLite project management repos - Remove workspace_id from worker tasks (storage keys, entity creation) - Remove workspace_id from video dedup and title usage modules - Remove workspace_id from generation and ingest worker tasks - Clean workspace_id from all test files and scripts - Remove workspace-specific test files (list_workspaces, workspace repos) Task: #14 workspace_id 残留清理
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),
|
|
]
|
|
)
|