diff --git a/tests/unit/test_1749_edit_plan_service_new_methods.py b/tests/unit/test_1749_edit_plan_service_new_methods.py index bf59519a5..af766224e 100644 --- a/tests/unit/test_1749_edit_plan_service_new_methods.py +++ b/tests/unit/test_1749_edit_plan_service_new_methods.py @@ -9,9 +9,9 @@ from unittest.mock import MagicMock, patch import pytest - # ── helpers ─────────────────────────────────────────────────────────────────── + def _make_svc(): """构造 EditPlanService,mock 掉 DB/repos。""" from app.services.edit_plan_service import EditPlanService @@ -165,22 +165,20 @@ class TestEnsureVariantPlans: def test_count_1_with_voice(self): svc = self._setup_svc() - result = svc.ensure_variant_plans( - "src", 1, ["a1"], voice_durations=[30.0] - ) + result = svc.ensure_variant_plans("src", 1, ["a1"], voice_durations=[30.0]) assert result == ["plan_v0"] svc.apply_voice_duration_to_plan.assert_called_once_with("plan_v0", 30.0) def test_count_3_with_voice(self): svc = self._setup_svc() - svc.reselect_plan_for_variant = MagicMock(side_effect=[ - MagicMock(id="plan_v1"), - MagicMock(id="plan_v2"), - ]) - - result = svc.ensure_variant_plans( - "src", 3, ["a1", "a2"], voice_durations=[30.0, 20.0, 15.0] + svc.reselect_plan_for_variant = MagicMock( + side_effect=[ + MagicMock(id="plan_v1"), + MagicMock(id="plan_v2"), + ] ) + + result = svc.ensure_variant_plans("src", 3, ["a1", "a2"], voice_durations=[30.0, 20.0, 15.0]) assert len(result) == 3 assert result[0] == "plan_v0" # v0 配音 @@ -191,7 +189,5 @@ class TestEnsureVariantPlans: def test_voice_apply_failure_not_blocking(self): svc = self._setup_svc() svc.apply_voice_duration_to_plan.side_effect = RuntimeError("boom") - result = svc.ensure_variant_plans( - "src", 1, ["a1"], voice_durations=[30.0] - ) + result = svc.ensure_variant_plans("src", 1, ["a1"], voice_durations=[30.0]) assert result == ["plan_v0"] diff --git a/tests/unit/test_1749_preview_batch_voice_allocation.py b/tests/unit/test_1749_preview_batch_voice_allocation.py index d94fa4029..9882c4ba4 100644 --- a/tests/unit/test_1749_preview_batch_voice_allocation.py +++ b/tests/unit/test_1749_preview_batch_voice_allocation.py @@ -7,13 +7,13 @@ from __future__ import annotations -from unittest.mock import MagicMock, patch, call +from unittest.mock import MagicMock, call, patch import pytest - # ── 辅助 ────────────────────────────────────────────────────────────────────── + def _make_user(): mu = MagicMock() mu.user.id = "u1" diff --git a/tests/unit/test_1749_variant_plans_route.py b/tests/unit/test_1749_variant_plans_route.py index 3e4068652..40a1a4303 100644 --- a/tests/unit/test_1749_variant_plans_route.py +++ b/tests/unit/test_1749_variant_plans_route.py @@ -14,7 +14,6 @@ from __future__ import annotations from unittest.mock import MagicMock, patch import pytest - from fastapi import HTTPException