Merge pull request #7050 from DDSRem-Dev/codex-comment-migration

docs: 统一全项目中文注释和结构化契约说明
This commit is contained in:
DDSRem
2026-10-17 19:26:29 +08:00
committed by GitHub
parent 3c7431b7da
commit 2de976f6b3
2345 changed files with 143990 additions and 61534 deletions

View File

@@ -1,4 +1,6 @@
"""工作流空媒体、缺失评分及未知下载进度的边界行为。"""
"""
工作流空媒体、缺失评分及未知下载进度的边界行为。
"""
from pathlib import Path
from types import SimpleNamespace
@@ -13,7 +15,9 @@ from app.workflow.actions.filter_medias import FilterMediasAction
def test_missing_media_collection_finishes_empty():
"""Schema 允许的空媒体集合按零条输入完成过滤。"""
"""
Schema 允许的空媒体集合按零条输入完成过滤。
"""
action = FilterMediasAction("filter")
context = ActionContext(medias=None)
assert action.execute(1, {}, context) is context
@@ -23,7 +27,9 @@ def test_missing_media_collection_finishes_empty():
@pytest.mark.parametrize("minimum", [0.0, 5.0])
def test_unknown_rating_cannot_satisfy_minimum(minimum):
"""指定最低评分时,缺失评分的条目不能被当作已达到要求。"""
"""
指定最低评分时,缺失评分的条目不能被当作已达到要求。
"""
action = FilterMediasAction("filter")
context = ActionContext(medias=[MediaInfo(title="unknown", vote_average=None)])
assert action.execute(1, {"vote": minimum}, context).medias == []
@@ -32,7 +38,9 @@ def test_unknown_rating_cannot_satisfy_minimum(minimum):
@pytest.mark.parametrize("minimum,expected", [(None, ["unknown", "zero", "low", "edge", "high"]), (5.0, ["edge", "high"])])
def test_rating_filter_preserves_known_boundary_and_order(minimum, expected):
"""未启用评分过滤时保留所有条目,启用时保留相等边界及原始顺序。"""
"""
未启用评分过滤时保留所有条目,启用时保留相等边界及原始顺序。
"""
context = ActionContext(medias=[MediaInfo(title=name, vote_average=score) for name, score in [("unknown", None), ("zero", 0.0), ("low", 4.9), ("edge", 5.0), ("high", 8.0)]])
action = FilterMediasAction("filter")
result = action.execute(1, {"vote": minimum}, context)
@@ -41,7 +49,9 @@ def test_rating_filter_preserves_known_boundary_and_order(minimum, expected):
@pytest.mark.parametrize("progress,completed", [(None, False), (0, False), (99.9, False), (100, True), (101, True)])
def test_unknown_download_progress_remains_incomplete(monkeypatch, progress, completed):
"""仅已知达到 100 的下载进度能完成任务,未知值保留为未完成。"""
"""
仅已知达到 100 的下载进度能完成任务,未知值保留为未完成。
"""
chain = SimpleNamespace(list_torrents=lambda **_kwargs: [SimpleNamespace(path="/downloads/file.mkv", progress=progress)])
monkeypatch.setattr(downloads_module, "ActionChain", lambda: chain)
monkeypatch.setattr(downloads_module.runtime_stop_state, "is_workflow_stopped", lambda _workflow_id: False)
@@ -55,7 +65,9 @@ def test_unknown_download_progress_remains_incomplete(monkeypatch, progress, com
@pytest.mark.parametrize("path,expected", [(Path("/downloads/file.mkv"), "/downloads/file.mkv"), (None, None), ("", "")])
def test_download_paths_remain_serializable_text(monkeypatch, path, expected):
"""下载链的 Path 转为工作流 Schema 的字符串,空值和已有字符串保持原义。"""
"""
下载链的 Path 转为工作流 Schema 的字符串,空值和已有字符串保持原义。
"""
chain = SimpleNamespace(list_torrents=lambda **_kwargs: [SimpleNamespace(path=path, progress=100)])
monkeypatch.setattr(downloads_module, "ActionChain", lambda: chain)
monkeypatch.setattr(downloads_module.runtime_stop_state, "is_workflow_stopped", lambda _workflow_id: False)