修复手动整理按集数定位模板过滤 (#6043)

This commit is contained in:
Album
2026-07-03 07:55:59 +08:00
committed by GitHub
parent f3e5be37fd
commit 6c3c5e042d
5 changed files with 630 additions and 36 deletions
+105
View File
@@ -53,6 +53,111 @@ def test_manual_transfer_from_history_preserves_download_context(monkeypatch):
assert captured["season"] == 1
def test_manual_transfer_from_history_passes_old_dest_cleanup_to_chain(monkeypatch):
history = SimpleNamespace(
status=0,
mode="copy",
src_fileitem={
"storage": "local",
"path": "/downloads/test.mkv",
"name": "test.mkv",
"type": "file",
},
dest_fileitem={
"storage": "local",
"path": "/library/test.mkv",
"name": "test.mkv",
"type": "file",
},
downloader="qbittorrent",
download_hash="abc123",
type=None,
tmdbid=None,
doubanid=None,
seasons=None,
episodes=None,
episode_group=None,
)
captured = {}
def fake_get(_db, logid):
assert logid == 1
return history
class FakeTransferChain:
def manual_transfer(self, **kwargs):
captured.update(kwargs)
return True, ""
monkeypatch.setattr("app.api.endpoints.transfer.TransferHistory.get", fake_get)
monkeypatch.setattr("app.api.endpoints.transfer.TransferChain", FakeTransferChain)
resp = manual_transfer(
transer_item=ManualTransferItem(logid=1),
background=False,
db=object(),
_="token",
)
assert resp.success is True
assert captured["fileitem"].path == "/downloads/test.mkv"
assert captured["cleanup_dest_fileitem"].path == "/library/test.mkv"
def test_manual_transfer_from_history_preview_does_not_cleanup_old_dest(monkeypatch):
history = SimpleNamespace(
status=0,
mode="copy",
src_fileitem={
"storage": "local",
"path": "/downloads/test.mkv",
"name": "test.mkv",
"type": "file",
},
dest_fileitem={
"storage": "local",
"path": "/library/test.mkv",
"name": "test.mkv",
"type": "file",
},
downloader="qbittorrent",
download_hash="abc123",
type=None,
tmdbid=None,
doubanid=None,
seasons=None,
episodes=None,
episode_group=None,
)
captured = {}
def fake_get(_db, logid):
assert logid == 1
return history
class FakeTransferChain:
def manual_transfer(self, **kwargs):
captured.update(kwargs)
return True, {
"summary": {"total": 0, "success": 0, "failed": 0},
"items": [],
"message": "",
}
monkeypatch.setattr("app.api.endpoints.transfer.TransferHistory.get", fake_get)
monkeypatch.setattr("app.api.endpoints.transfer.TransferChain", FakeTransferChain)
resp = manual_transfer(
transer_item=ManualTransferItem(logid=1, preview=True),
background=False,
db=object(),
_="token",
)
assert resp.success is True
assert captured["cleanup_dest_fileitem"] is None
def test_manual_transfer_preview_uses_explicit_fileitems_instead_of_directory(monkeypatch):
dir_item = {
"storage": "local",