feat(apply): block abnormal product statuses
This commit is contained in:
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user