feat: 采集按分组选表和固定时刻运行,号池可检查凭证,管理页不再退出

This commit is contained in:
2026-11-09 17:55:31 +08:00
parent 152cf92df9
commit 78ad5cea6b
19 changed files with 554 additions and 247 deletions
+20
View File
@@ -0,0 +1,20 @@
from datetime import datetime
from zoneinfo import ZoneInfo
from app.collect.schedule import next_run_at
ZONE = ZoneInfo("Asia/Shanghai")
def test_weekly_and_monthly_next_run():
now = datetime(2026, 11, 9, 10, 0, tzinfo=ZONE)
weekly_later = next_run_at({"mode": "weekly", "weekday": 1, "time": "18:00"}, now)
assert weekly_later.astimezone(ZONE).strftime("%Y-%m-%d %H:%M") == "2026-11-09 18:00"
weekly_next = next_run_at({"mode": "weekly", "weekday": 1, "time": "08:00"}, now)
assert weekly_next.astimezone(ZONE).strftime("%Y-%m-%d %H:%M") == "2026-11-16 08:00"
monthly_soon = next_run_at({"mode": "monthly", "monthDay": 15, "time": "09:30"}, now)
assert monthly_soon.astimezone(ZONE).strftime("%Y-%m-%d %H:%M") == "2026-11-15 09:30"
monthly_passed = next_run_at({"mode": "monthly", "monthDay": 9, "time": "08:00"}, now)
assert monthly_passed.astimezone(ZONE).strftime("%Y-%m-%d %H:%M") == "2026-12-09 08:00"
month_end = next_run_at({"mode": "monthly", "monthDay": 31, "time": "08:00"}, datetime(2026, 2, 1, 0, 0, tzinfo=ZONE))
assert month_end.astimezone(ZONE).strftime("%Y-%m-%d %H:%M") == "2026-02-28 08:00"