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
82 lines
2.8 KiB
Python
82 lines
2.8 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "apps" / "api"))
|
|
|
|
from app.api.routes.asset_diagnosis import _build_diagnosis
|
|
|
|
from packages.domain import Asset, AssetStatus, ClassificationStatus
|
|
|
|
|
|
def _asset(name: str, mime_type: str, *, status=AssetStatus.READY, duration=None, quality_score=None):
|
|
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,
|
|
duration=duration,
|
|
status=status,
|
|
classification_status=ClassificationStatus.COMPLETED,
|
|
quality_score=quality_score,
|
|
)
|
|
|
|
|
|
def test_asset_diagnosis_reports_missing_video_gap():
|
|
diagnosis = _build_diagnosis(
|
|
"workspace-1",
|
|
"project-1",
|
|
[_asset("voice.mp3", "audio/mpeg"), _asset("image.jpg", "image/jpeg")],
|
|
)
|
|
|
|
assert diagnosis.readiness_score < 80
|
|
assert diagnosis.video_assets == 0
|
|
assert any(gap.key == "missing_video" and gap.severity == "critical" for gap in diagnosis.gaps)
|
|
|
|
|
|
def test_asset_diagnosis_scores_ready_video_assets():
|
|
used_asset = _asset("video-1.mp4", "video/mp4", duration=8)
|
|
used_asset.metadata = {"generation_use_count": 1, "review_status": "pending_review"}
|
|
diagnosis = _build_diagnosis(
|
|
"workspace-1",
|
|
"project-1",
|
|
[
|
|
used_asset,
|
|
_asset("video-2.mp4", "video/mp4", duration=8),
|
|
_asset("video-3.mov", "video/quicktime", duration=8),
|
|
_asset("voice.mp3", "audio/mpeg"),
|
|
],
|
|
)
|
|
|
|
assert diagnosis.readiness_score >= 80
|
|
assert diagnosis.video_assets == 3
|
|
assert diagnosis.voice_assets == 1
|
|
assert diagnosis.estimated_video_count == 3
|
|
assert diagnosis.used_assets == 1
|
|
assert diagnosis.unused_assets == 3
|
|
assert diagnosis.pending_review_assets == 1
|
|
smart_view_counts = {item.key: item.count for item in diagnosis.smart_views}
|
|
assert smart_view_counts["recommended"] == 3
|
|
assert smart_view_counts["used"] == 1
|
|
assert smart_view_counts["pending_review"] == 1
|
|
|
|
|
|
def test_asset_diagnosis_flags_unready_and_low_quality_assets():
|
|
diagnosis = _build_diagnosis(
|
|
"workspace-1",
|
|
"project-1",
|
|
[
|
|
_asset("video.mp4", "video/mp4", duration=10, quality_score=40),
|
|
_asset("pending.mp4", "video/mp4", status=AssetStatus.UPLOADING),
|
|
],
|
|
)
|
|
|
|
gap_keys = {gap.key for gap in diagnosis.gaps}
|
|
assert "not_ready_assets" in gap_keys
|
|
assert "low_quality_assets" in gap_keys
|
|
smart_view_counts = {item.key: item.count for item in diagnosis.smart_views}
|
|
assert smart_view_counts["needs_attention"] == 2
|
|
assert smart_view_counts["high_risk"] == 1
|