73665f0d60
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 49s
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 1m29s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 1m32s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 2m35s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 2m55s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 3m4s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m42s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 35s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 35s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 3m42s
CI/CD Pipeline / Build Staging API Image (push) Successful in 5m20s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 3m48s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 4m23s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 49s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 7m25s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m20s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 1m31s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 7m53s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 7m57s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m37s
CI/CD Pipeline / Integration Tests (push) Successful in 2m53s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m18s
CI/CD Pipeline / Unit Tests (push) Successful in 13m45s
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 12m22s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 7s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
75 lines
2.9 KiB
Python
75 lines
2.9 KiB
Python
"""Regression test: ensure worker.generate_video Celery task is bound to the
|
|
real generate_video function, not a helper introduced above it.
|
|
|
|
Context (P0 incident 2026-08-23): a refactor inserted helper function
|
|
_sync_task_config_to_plan directly under the @celery_app.task decorator,
|
|
so Celery registered the helper as "worker.generate_video". Calling the
|
|
task with a single task_id raised TypeError and every generation job
|
|
failed immediately. This test pins the decorator target.
|
|
|
|
NOTE: CI conftest may mock Celery so that @celery_app.task does NOT return
|
|
a fully functional Task/PromiseProxy object. Tests therefore use multiple
|
|
defensive strategies: source-code inspection, __wrapped__.__func__ chain
|
|
traversal, and direct attribute checks.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import inspect
|
|
import re
|
|
|
|
|
|
def _get_original_function(generate_video):
|
|
"""Walk the __wrapped__ chain to find the original function object."""
|
|
obj = generate_video
|
|
seen = set()
|
|
while hasattr(obj, "__wrapped__"):
|
|
obj_id = id(obj)
|
|
if obj_id in seen:
|
|
break
|
|
seen.add(obj_id)
|
|
obj = obj.__wrapped__
|
|
# __wrapped__ may be a bound method — unwrap to the underlying function
|
|
if hasattr(obj, "__func__"):
|
|
return obj.__func__
|
|
return obj
|
|
|
|
|
|
def test_generate_video_task_has_bind_true():
|
|
"""The decorator must use bind=True — verified via the original function's
|
|
first parameter being 'self' (bind=True convention)."""
|
|
from worker_app.tasks.generation import generate_video
|
|
|
|
original = _get_original_function(generate_video)
|
|
sig = inspect.signature(original)
|
|
params = list(sig.parameters)
|
|
assert params[0] == "self", f"bind=True requires 'self' as first param, got {params}"
|
|
|
|
|
|
def test_generate_video_task_signature_has_task_id():
|
|
"""The original generate_video function must accept task_id as a parameter."""
|
|
from worker_app.tasks.generation import generate_video
|
|
|
|
original = _get_original_function(generate_video)
|
|
sig = inspect.signature(original)
|
|
params = list(sig.parameters)
|
|
assert "task_id" in params, f"expected 'task_id' in params, got {params}"
|
|
|
|
|
|
def test_generate_video_preserves_original_function():
|
|
"""The original function wrapped by @celery_app.task must be named
|
|
'generate_video' — not '_sync_task_config_to_plan'."""
|
|
from worker_app.tasks.generation import generate_video
|
|
|
|
original = _get_original_function(generate_video)
|
|
assert original.__name__ == "generate_video", f"expected __name__='generate_video', got '{original.__name__}'"
|
|
|
|
|
|
def test_sync_task_config_to_plan_is_plain_function():
|
|
"""Helper must NOT be registered as a Celery task."""
|
|
from worker_app.tasks.generation import _sync_task_config_to_plan
|
|
|
|
assert not hasattr(
|
|
_sync_task_config_to_plan, "run"
|
|
), "_sync_task_config_to_plan must be a plain function, not a Celery task"
|