Files
xiaoxia-saas/tests/unit/test_edit_plan.py
xiaoxia 78afa40458
CI/CD Pipeline / Check if frontend-only change (push) Blocked by required conditions
CI/CD Pipeline / Validate - Code Quality (push) Blocked by required conditions
CI/CD Pipeline / Validate - Type Check (mypy) (push) Blocked by required conditions
CI/CD Pipeline / Validate - Migration (alembic) (push) Blocked by required conditions
CI/CD Pipeline / Unit Tests (push) Blocked by required conditions
CI/CD Pipeline / Integration Tests (push) Blocked by required conditions
CI/CD Pipeline / Frontend Lint (push) Blocked by required conditions
CI/CD Pipeline / Frontend Unit Tests (push) Blocked by required conditions
CI/CD Pipeline / PR Build API Image (push) Blocked by required conditions
CI/CD Pipeline / PR Build Web Image (push) Blocked by required conditions
CI/CD Pipeline / PR Build Worker Image (push) Blocked by required conditions
CI/CD Pipeline / Build Staging API Image (push) Blocked by required conditions
CI/CD Pipeline / Build Staging Web Image (push) Blocked by required conditions
CI/CD Pipeline / Build Staging Worker Image (push) Blocked by required conditions
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Blocked by required conditions
CI/CD Pipeline / Staging E2E Tests (push) Blocked by required conditions
CI/CD Pipeline / Staging API Integration Tests (push) Blocked by required conditions
CI/CD Pipeline / Build Production API Image (push) Blocked by required conditions
CI/CD Pipeline / Build Production Web Image (push) Blocked by required conditions
CI/CD Pipeline / Build Production Worker Image (push) Blocked by required conditions
CI/CD Pipeline / Deploy Production (push) Blocked by required conditions
CI/CD Pipeline / Production Browser E2E (push) Blocked by required conditions
CI/CD Pipeline / ACR Image Cleanup (push) Blocked by required conditions
test: P3-1 第50波单元测试(generation_task/edit_plan/edit_template/edit_plan_clip,+86) (#838)
2026-07-24 18:58:21 +08:00

79 lines
2.8 KiB
Python
Executable File

"""EditPlan 剪辑计划领域实体单测."""
import pytest
from packages.domain.edit_plan import EditPlan, EditPlanStatus
class TestEditPlanStatus:
def test_values(self):
assert EditPlanStatus.DRAFT.value == "draft"
assert EditPlanStatus.EDITING.value == "editing"
assert EditPlanStatus.RENDERING.value == "rendering"
assert EditPlanStatus.COMPLETED.value == "completed"
assert EditPlanStatus.FAILED.value == "failed"
def test_is_str(self):
assert isinstance(EditPlanStatus.DRAFT, str)
class TestEditPlanCreate:
def test_create_normal(self):
plan = EditPlan.create(template_id="tmpl1", name="我的剪辑计划")
assert plan.id
assert plan.template_id == "tmpl1"
assert plan.name == "我的剪辑计划"
assert plan.status == EditPlanStatus.DRAFT
assert plan.total_duration == 0.0
assert plan.config == {}
def test_create_strips_whitespace(self):
plan = EditPlan.create(
template_id=" tmpl1 ",
name=" 我的计划 ",
source_edit_plan_id=" src1 ",
project_id=" proj1 ",
created_by_user_id=" user1 ",
)
assert plan.template_id == "tmpl1"
assert plan.name == "我的计划"
assert plan.source_edit_plan_id == "src1"
assert plan.project_id == "proj1"
assert plan.created_by_user_id == "user1"
def test_create_empty_name_raises(self):
with pytest.raises(ValueError, match="计划名称不能为空"):
EditPlan.create(template_id="tmpl1", name="")
def test_create_whitespace_name_raises(self):
with pytest.raises(ValueError, match="计划名称不能为空"):
EditPlan.create(template_id="tmpl1", name=" ")
def test_create_empty_template_id_raises(self):
with pytest.raises(ValueError, match="template_id 不能为空"):
EditPlan.create(template_id="", name="计划")
def test_create_whitespace_template_id_raises(self):
with pytest.raises(ValueError, match="template_id 不能为空"):
EditPlan.create(template_id=" ", name="计划")
def test_create_with_config(self):
config = {"resolution": "1080p", "fps": 30}
plan = EditPlan.create(
template_id="tmpl1",
name="计划",
config=config,
total_duration=30.5,
)
assert plan.config == config
assert plan.total_duration == 30.5
def test_create_none_config_defaults_to_empty(self):
plan = EditPlan.create(template_id="tmpl1", name="计划", config=None)
assert plan.config == {}
def test_create_unique_ids(self):
p1 = EditPlan.create(template_id="t1", name="p1")
p2 = EditPlan.create(template_id="t1", name="p2")
assert p1.id != p2.id