fix: update tests for repo.get() signature + add user_id param
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 40s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 53s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m1s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m18s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m41s
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 1046h2m31s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 1046h3m10s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1046h3m10s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 1046h3m14s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 1046h3m14s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 1046h2m32s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1046h3m11s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 1046h3m14s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 1046h35m47s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 1046h36m27s

This commit is contained in:
2026-08-04 01:18:58 +08:00
parent 71c606e82e
commit 4c09253915
+32 -18
View File
@@ -1173,9 +1173,11 @@ class TestInferVideoRatioFromTemplate:
mock_template.mode = "pip"
mock_db = MagicMock()
with patch("app.api.routes.generation_preview.SQLAlchemyTemplateRepository") as MockRepo:
MockRepo.return_value.get_by_id.return_value = mock_template
result = _infer_video_ratio_from_template("tpl_001", mock_db)
with patch(
"app.api.routes.generation_preview.SQLAlchemyTemplateRepository"
) as MockRepo:
MockRepo.return_value.get.return_value = mock_template
result = _infer_video_ratio_from_template("tpl_001", mock_db, "user_1")
assert result == "9:16"
def test_standard_mode_returns_16_9(self):
@@ -1186,9 +1188,11 @@ class TestInferVideoRatioFromTemplate:
mock_template.mode = "standard"
mock_db = MagicMock()
with patch("app.api.routes.generation_preview.SQLAlchemyTemplateRepository") as MockRepo:
MockRepo.return_value.get_by_id.return_value = mock_template
result = _infer_video_ratio_from_template("tpl_001", mock_db)
with patch(
"app.api.routes.generation_preview.SQLAlchemyTemplateRepository"
) as MockRepo:
MockRepo.return_value.get.return_value = mock_template
result = _infer_video_ratio_from_template("tpl_001", mock_db, "user_1")
assert result == "16:9"
def test_unknown_mode_returns_empty(self):
@@ -1199,9 +1203,11 @@ class TestInferVideoRatioFromTemplate:
mock_template.mode = "unknown_mode"
mock_db = MagicMock()
with patch("app.api.routes.generation_preview.SQLAlchemyTemplateRepository") as MockRepo:
MockRepo.return_value.get_by_id.return_value = mock_template
result = _infer_video_ratio_from_template("tpl_001", mock_db)
with patch(
"app.api.routes.generation_preview.SQLAlchemyTemplateRepository"
) as MockRepo:
MockRepo.return_value.get.return_value = mock_template
result = _infer_video_ratio_from_template("tpl_001", mock_db, "user_1")
assert result == ""
def test_template_not_found_returns_empty(self):
@@ -1210,9 +1216,11 @@ class TestInferVideoRatioFromTemplate:
mock_db = MagicMock()
with patch("app.api.routes.generation_preview.SQLAlchemyTemplateRepository") as MockRepo:
MockRepo.return_value.get_by_id.return_value = None
result = _infer_video_ratio_from_template("nonexistent", mock_db)
with patch(
"app.api.routes.generation_preview.SQLAlchemyTemplateRepository"
) as MockRepo:
MockRepo.return_value.get.return_value = None
result = _infer_video_ratio_from_template("nonexistent", mock_db, "user_1")
assert result == ""
def test_empty_template_id_returns_empty(self):
@@ -1220,7 +1228,7 @@ class TestInferVideoRatioFromTemplate:
from app.api.routes.generation_preview import _infer_video_ratio_from_template
mock_db = MagicMock()
result = _infer_video_ratio_from_template("", mock_db)
result = _infer_video_ratio_from_template("", mock_db, "user_1")
assert result == ""
def test_db_exception_returns_empty(self):
@@ -1229,9 +1237,11 @@ class TestInferVideoRatioFromTemplate:
mock_db = MagicMock()
with patch("app.api.routes.generation_preview.SQLAlchemyTemplateRepository") as MockRepo:
with patch(
"app.api.routes.generation_preview.SQLAlchemyTemplateRepository"
) as MockRepo:
MockRepo.side_effect = Exception("db connection error")
result = _infer_video_ratio_from_template("tpl_001", mock_db)
result = _infer_video_ratio_from_template("tpl_001", mock_db, "user_1")
assert result == ""
@@ -1264,9 +1274,13 @@ class TestPreviewRouteAutoInfersVideoRatio:
bgm_config={},
)
with patch("app.api.routes.generation_preview.SQLAlchemyTemplateRepository") as MockRepo:
MockRepo.return_value.get_by_id.return_value = mock_template
with patch("app.api.routes.generation_preview.CreateGenerationTaskUseCase") as MockUC:
with patch(
"app.api.routes.generation_preview.SQLAlchemyTemplateRepository"
) as MockRepo:
MockRepo.return_value.get.return_value = mock_template
with patch(
"app.api.routes.generation_preview.CreateGenerationTaskUseCase"
) as MockUC:
MockUC.return_value.execute.return_value = task
with patch(
"app.api.routes.generation_preview.safe_enqueue_generation_task",