test: fix mock path for celery_app (moved to task_enqueue module)
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 1m14s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1609h32m14s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1609h32m16s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1609h32m16s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Failing after 1609h32m18s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1610h3m50s
CI/CD Pipeline / Build Production Runtime Images (pull_request) Failing after 1610h3m52s

This commit is contained in:
2026-07-11 13:54:12 +08:00
parent 40145d61cf
commit b61e021bb6
+10 -10
View File
@@ -241,7 +241,7 @@ def client():
class TestCreateGenerationTask:
"""创建生成任务端点测试。"""
@patch("app.api.routes.generation_tasks.celery_app")
@patch("app.core.task_enqueue.celery_app")
def test_create_task_success(self, mock_celery, client):
"""正常创建生成任务成功。"""
mock_celery.send_task = MagicMock()
@@ -270,7 +270,7 @@ class TestCreateGenerationTask:
assert mock_celery.send_task.called
assert mock_celery.send_task.call_args[0][0] == "worker.generate_video"
@patch("app.api.routes.generation_tasks.celery_app")
@patch("app.core.task_enqueue.celery_app")
def test_create_batch_tasks(self, mock_celery, client):
"""批量创建多个生成任务。"""
mock_celery.send_task = MagicMock()
@@ -347,7 +347,7 @@ class TestListGenerationTasks:
def _create_task(self, client, task_suffix: str = "1"):
"""辅助方法:创建一个生成任务。"""
with patch("app.api.routes.generation_tasks.celery_app") as mock_celery:
with patch("app.core.task_enqueue.celery_app") as mock_celery:
mock_celery.send_task = MagicMock()
resp = client.post(
"/api/v1/generation/tasks",
@@ -368,7 +368,7 @@ class TestListGenerationTasks:
assert "items" in data
assert data["items"] == []
@patch("app.api.routes.generation_tasks.celery_app")
@patch("app.core.task_enqueue.celery_app")
def test_list_returns_user_tasks(self, mock_celery, client):
"""返回当前用户的生成任务列表。"""
mock_celery.send_task = MagicMock()
@@ -406,7 +406,7 @@ class TestGetGenerationTask:
"""获取生成任务详情端点测试。"""
def _create_task(self, client) -> str:
with patch("app.api.routes.generation_tasks.celery_app") as mock_celery:
with patch("app.core.task_enqueue.celery_app") as mock_celery:
mock_celery.send_task = MagicMock()
resp = client.post(
"/api/v1/generation/tasks",
@@ -449,7 +449,7 @@ class TestListGenerationResults:
"""列出生成结果端点测试。"""
def _create_task(self, client) -> str:
with patch("app.api.routes.generation_tasks.celery_app") as mock_celery:
with patch("app.core.task_enqueue.celery_app") as mock_celery:
mock_celery.send_task = MagicMock()
resp = client.post(
"/api/v1/generation/tasks",
@@ -489,7 +489,7 @@ class TestRetryGenerationTask:
def _create_failed_task(self, client) -> str:
"""创建一个失败状态的任务。"""
with patch("app.api.routes.generation_tasks.celery_app") as mock_celery:
with patch("app.core.task_enqueue.celery_app") as mock_celery:
mock_celery.send_task = MagicMock()
resp = client.post(
"/api/v1/generation/tasks",
@@ -509,7 +509,7 @@ class TestRetryGenerationTask:
# 让我们直接通过 retry 测试来验证
return task_id
@patch("app.api.routes.generation_tasks.celery_app")
@patch("app.core.task_enqueue.celery_app")
def test_retry_failed_task(self, mock_celery, client):
"""重试失败的任务成功。"""
mock_celery.send_task = MagicMock()
@@ -539,7 +539,7 @@ class TestRetryGenerationTask:
assert resp.status_code == 404
assert "not found" in resp.json()["detail"].lower()
@patch("app.api.routes.generation_tasks.celery_app")
@patch("app.core.task_enqueue.celery_app")
def test_retry_completed_task_returns_409(self, mock_celery, client):
"""重试已完成的任务返回 409。"""
mock_celery.send_task = MagicMock()
@@ -568,7 +568,7 @@ class TestRetryGenerationTask:
class TestGenerationTaskFlow:
"""生成任务完整流程集成测试。"""
@patch("app.api.routes.generation_tasks.celery_app")
@patch("app.core.task_enqueue.celery_app")
def test_create_list_detail_results_flow(self, mock_celery, client):
"""测试创建 → 列表 → 详情 → 结果 完整流程。"""
mock_celery.send_task = MagicMock()