feat(collect): choose product status scope

This commit is contained in:
chengma
2026-07-18 16:46:59 +08:00
parent 0cf23db403
commit 4658a1ca61
11 changed files with 420 additions and 41 deletions
+27
View File
@@ -971,6 +971,33 @@ class EditorLoginTests(unittest.TestCase):
steps,
)
def test_collect_normal_only_skips_non_normal_before_reading_content(self):
cdp = FakeProductCDP(
"ws-status",
alerts=[{"title": "您的商品未上架", "description": "已下架"}],
)
with mock.patch("app.editor.open_product", return_value=cdp), mock.patch(
"app.editor.read_title"
) as read_title, mock.patch("app.editor.read_cover_src") as read_cover_src, mock.patch(
"app.editor.download_cover"
) as download_cover:
result = editor.collect(
{"debug_port": 9222},
{
"item_id": "51100639510",
"old_cover_path": "old.jpg",
"collection_scope": "normal_only",
},
)
self.assertTrue(result["collection_skipped"])
self.assertEqual("unlisted", result["product_status"])
self.assertEqual("未上架,按本轮范围略过", result["collection_skip_reason"])
read_title.assert_not_called()
read_cover_src.assert_not_called()
download_cover.assert_not_called()
def test_collect_keeps_reused_product_tab_open(self):
cdp = FakeProductCDP("ws-existing")
cdp.target_id = "target-existing"