fix(workflow): use core torrent info for RSS action (#5786)

This commit is contained in:
InfinityPacer
2026-05-19 13:04:03 +08:00
committed by GitHub
parent f46488cb9c
commit b989d08385
3 changed files with 51 additions and 2 deletions

View File

@@ -232,6 +232,8 @@ class TorrentInfo(BaseModel):
labels: Optional[list] = Field(default_factory=list)
# 种子优先级
pri_order: Optional[int] = 0
# 种子分类 电影/电视剧
category: Optional[str] = None
# 促销
volume_factor: Optional[str] = None
# 剩余免费时间

View File

@@ -5,11 +5,11 @@ from pydantic import Field
from app.workflow.actions import BaseAction
from app.chain.media import MediaChain
from app.core.config import settings, global_vars
from app.core.context import Context
from app.core.context import Context, TorrentInfo
from app.core.metainfo import MetaInfo
from app.helper.rss import RssHelper
from app.log import logger
from app.schemas import ActionParams, ActionContext, TorrentInfo
from app.schemas import ActionParams, ActionContext
class FetchRssParams(ActionParams):

View File

@@ -0,0 +1,47 @@
import unittest
from datetime import datetime
from unittest.mock import patch
from app.core.context import TorrentInfo
from app.schemas import ActionContext
from app.workflow.actions.fetch_rss import FetchRssAction
class FetchRssActionTest(unittest.TestCase):
"""
RSS 工作流动作测试。
"""
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.global_vars.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(),
)
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)
if __name__ == "__main__":
unittest.main()