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,7 @@
import unittest
"""
验证 RSS 工作流动作的输入解析与结果输出。
"""
from datetime import datetime
from unittest.mock import patch
@@ -7,37 +10,34 @@ from app.schemas.workflow import ActionContext
from app.workflow.actions.fetch_rss import FetchRssAction
class FetchRssActionTest(unittest.TestCase):
def test_execute_builds_core_torrent_info_for_downstream_workflow() -> None:
"""
RSS 工作流动作测试。
工作流产出的种子信息应使用 core TorrentInfo,避免下载事件下游收到缺少运行时接口的 schema 对象。
"""
rss_items = [
{
"title": "Example RSS Torrent",
"enclosure": "https://example.com/example.torrent",
"link": "https://example.com/details",
"size": 1024,
"pubdate": datetime(2026, 5, 19, 8, 30, 0),
}
]
def test_execute_builds_core_torrent_info_for_downstream_workflow(self):
"""
工作流产出的种子信息应使用 core TorrentInfo,避免下载事件下游收到缺少运行时接口的 schema 对象。
"""
rss_items = [
{
"title": "Example RSS Torrent",
"enclosure": "https://example.com/example.torrent",
"link": "https://example.com/details",
"size": 1024,
"pubdate": datetime(2026, 5, 19, 8, 30, 0),
}
]
with (
patch("app.workflow.actions.fetch_rss.RssHelper") as rss_helper,
patch("app.workflow.actions.fetch_rss.runtime_stop_state.is_workflow_stopped", return_value=False),
):
rss_helper.return_value.parse.return_value = rss_items
with patch("app.workflow.actions.fetch_rss.RssHelper") as rss_helper, \
patch("app.workflow.actions.fetch_rss.runtime_stop_state.is_workflow_stopped", return_value=False):
rss_helper.return_value.parse.return_value = rss_items
context = FetchRssAction("fetch-rss").execute(
workflow_id=1,
params={"url": "https://example.com/rss.xml"},
context=ActionContext(),
)
context = FetchRssAction("fetch-rss").execute(
workflow_id=1,
params={"url": "https://example.com/rss.xml"},
context=ActionContext(),
)
torrent_info = context.torrents[0].torrent_info
self.assertIsInstance(torrent_info, TorrentInfo)
self.assertIsNone(torrent_info.category)
self.assertTrue(callable(getattr(torrent_info, "to_dict", None)))
self.assertEqual("2026-05-19 08:30:00", torrent_info.pubdate)
torrent_info = context.torrents[0].torrent_info
assert isinstance(torrent_info, TorrentInfo)
assert torrent_info.category is None
assert callable(getattr(torrent_info, "to_dict", None))
assert "2026-05-19 08:30:00" == torrent_info.pubdate