Files
MoviePilot/tests/test_reliability_adr.py
freeman f3ad81b39e style: apply safe ruff auto-fixes and exempt startup late imports
Run `ruff check app tests scripts --fix` with the configured rule set
(E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders
(F541), lambda/variable/unused-import cleanups that ruff marks safe.
Nine files whose only ruff debt sits next to pre-existing pylint
import-resolution errors (lazy exports, sys.path script imports) or
whose "unused" imports are reached through attribute access by tests are
left untouched so the changed-file pylint gate and the benchmark tests
stay green; their diagnostics remain in the baseline.

app/startup/lifecycle/__init__.py and app/main.py import business
modules after cache composition, import-path and stdio setup on purpose
(the source comments document the contract), so declare E402
per-file-ignores for them instead of adding per-line noqa.

Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture
and the optimization checklist figure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 13:29:09 +08:00

36 lines
1.0 KiB
Python

"""后台动作可靠性 ADR 与事件登记一致性测试。"""
from pathlib import Path
from app.schemas.types import ChainEventType, EventType
ADR_PATH = Path(__file__).parents[1] / "docs" / "adr" / "0007-background-action-reliability.md"
def test_reliability_adr_names_every_event() -> None:
"""ADR 必须逐个提及全部广播和链式事件,不能只写笼统分组。"""
content = ADR_PATH.read_text(encoding="utf-8")
missing = [
event_type.name
for event_type in (*EventType, *ChainEventType)
if f"`{event_type.name}`" not in content
]
assert missing == []
def test_reliability_adr_covers_all_background_mechanisms() -> None:
"""ADR 必须覆盖方案要求的四类非 Event 后台机制和完成语义。"""
content = ADR_PATH.read_text(encoding="utf-8")
for phrase in (
"FastAPI BackgroundTasks",
"Scheduler jobs",
"Agent tasks",
"Transfer pending",
"完成点",
"dead letter",
"idempotency key",
):
assert phrase in content