旧验收项目自动补齐Cookie资源

This commit is contained in:
2026-09-02 11:49:55 +08:00
parent 718f681bb3
commit fc51e2a7c9
2 changed files with 62 additions and 0 deletions

View File

@@ -80,6 +80,34 @@ class AcceptanceCreationTest(unittest.TestCase):
self.assertEqual(task["schedule_start_time"], "20:00")
self.assertIsNotNone(task["next_run_at"])
self.assertEqual(task["keyword_runs"], [])
self.assertEqual(
[item["resource_id"] for item in task["resource_progress"] if item["resource_type"] == "cookie"],
["c1", "c2"],
)
@patch("acceptance_service.get_wen_resources")
def test_legacy_root_task_backfills_current_cookie_pool(self, resources):
resources.return_value = {"cookie_count": 2, "device_count": 3, "credential_ids": ["pool-1", "pool-2"]}
now = now_iso()
with connection() as conn:
task_id = conn.execute(
"""INSERT INTO acceptance_tasks
(public_task_id,name,acceptance_method,status,progress_percent,device_count,
created_by_id,created_by_name,created_at,updated_at,cookie_count)
VALUES ('legacy-root','旧项目','combined','completed',100,3,'u','u',?,?,2)""",
(now, now),
).lastrowid
conn.execute(
"INSERT INTO acceptance_keywords(task_id,keyword_order,keyword,created_at) VALUES (?,0,'山姆会员卡',?)",
(task_id, now),
)
task = get_acceptance_task("legacy-root")
self.assertEqual(
[item["resource_id"] for item in task["resource_progress"] if item["resource_type"] == "cookie"],
["pool-1", "pool-2"],
)
@patch("acceptance_service.threading.Thread", _ThreadWithoutStart)
@patch("acceptance_service.sync_dashboard_acceptance_project")