feat(apply): block abnormal product statuses

This commit is contained in:
chengma
2026-07-18 17:10:12 +08:00
parent 3a92119187
commit d64e3c7404
9 changed files with 499 additions and 51 deletions
+65
View File
@@ -132,3 +132,68 @@ class ProductStatusTests(unittest.TestCase):
)
self.assertEqual([1, 2, 3], [task.id if hasattr(task, "id") else task["id"] for task in all_statuses["execution_tasks"]])
self.assertNotEqual(normal_only["fingerprint"], changed["fingerprint"])
def test_apply_plan_excludes_abnormal_before_content_and_deduplicates_skips(self):
tasks = [
SimpleNamespace(
id=1,
updated_at="2026-07-18T10:00:00",
product_status="normal",
new_title="新标题",
new_cover_path="new.jpg",
),
SimpleNamespace(
id=2,
updated_at="2026-07-18T10:00:01",
product_status="unlisted",
new_title=None,
new_cover_path=None,
),
SimpleNamespace(
id=3,
updated_at="2026-07-18T10:00:02",
product_status="reviewing",
new_title=None,
new_cover_path="new.jpg",
),
SimpleNamespace(
id=4,
updated_at="2026-07-18T10:00:03",
product_status=None,
new_title="新标题",
new_cover_path=None,
),
SimpleNamespace(
id=5,
updated_at="2026-07-18T10:00:04",
product_status="normal",
new_title=None,
new_cover_path=None,
),
]
plan = product_status.build_apply_plan(tasks + [tasks[0]], "title_cover")
changed = product_status.build_apply_plan(
tasks[:4]
+ [
SimpleNamespace(
id=5,
updated_at="2026-07-18T10:01:00",
product_status="normal",
new_title=None,
new_cover_path=None,
)
],
"title_cover",
)
self.assertEqual([1], [task.id for task in plan["executable"]])
self.assertEqual([2], [task.id for task in plan["unlisted"]])
self.assertEqual([3], [task.id for task in plan["reviewing"]])
self.assertEqual([4], [task.id for task in plan["unknown"]])
self.assertEqual([5], [task.id for task in plan["missing_title"]])
self.assertEqual([5], [task.id for task in plan["missing_cover"]])
self.assertEqual(3, plan["status_scope_excluded"])
self.assertEqual(1, plan["content_scope_excluded"])
self.assertEqual(4, plan["scope_excluded"])
self.assertNotEqual(plan["fingerprint"], changed["fingerprint"])