diff --git a/apps/web/e2e/core-generation.spec.ts b/apps/web/e2e/core-generation.spec.ts index f260da572..3651e93a0 100755 --- a/apps/web/e2e/core-generation.spec.ts +++ b/apps/web/e2e/core-generation.spec.ts @@ -231,10 +231,7 @@ test.describe("Core generation flow", () => { (response) => { const url = response.url() const path = new URL(url).pathname - return ( - response.request().method() === "POST" && - path.endsWith("/generation/tasks") - ) + return response.request().method() === "POST" && path.endsWith("/generation/tasks") }, { timeout: 30_000 }, ) diff --git a/tests/unit/test_generation_worker_fixes.py b/tests/unit/test_generation_worker_fixes.py index edbd4ac2f..a1fd969e1 100644 --- a/tests/unit/test_generation_worker_fixes.py +++ b/tests/unit/test_generation_worker_fixes.py @@ -19,6 +19,7 @@ def _patch_session_local(mock_session): Uses patch.dict to inject a clean module so that 'from worker_app.db import SessionLocal' resolves correctly.""" from types import ModuleType + _fresh_db = ModuleType("worker_app.db") _fresh_db.SessionLocal = lambda *a, **kw: mock_session return patch.dict(sys.modules, {"worker_app.db": _fresh_db}) @@ -80,12 +81,15 @@ class TestLoadTemplateSegmentDurations: def test_db_error_returns_empty(self): """数据库异常返回空列表,不抛出。""" + from types import ModuleType + from worker_app.tasks.generation import _load_template_segment_durations - from types import ModuleType _err_db = ModuleType("worker_app.db") + def _raise(*a, **kw): raise Exception("DB down") + _err_db.SessionLocal = _raise with patch.dict(sys.modules, {"worker_app.db": _err_db}): result = _load_template_segment_durations("tpl_789") diff --git a/tests/unit/test_health_routes.py b/tests/unit/test_health_routes.py index bb15101eb..e41b1fdd2 100644 --- a/tests/unit/test_health_routes.py +++ b/tests/unit/test_health_routes.py @@ -159,6 +159,7 @@ class TestStartupCheck: async def test_startup_db_unhealthy(self): import json + from apps.api.app.api.routes import health with patch.object(health, "_check_migrations", new_callable=AsyncMock) as mock_mig, patch.object(health, "_check_database", new_callable=AsyncMock) as mock_db: