feat: 采集按分组选表和固定时刻运行,号池可检查凭证,管理页不再退出
This commit is contained in:
@@ -229,8 +229,8 @@ def test_admin_dashboard_and_user_password(client: TestClient):
|
||||
assert empty.json()["pool"]["total"] == 0
|
||||
now = utcnow()
|
||||
with session_scope() as session:
|
||||
session.add(NqiAccount(login_id="a1", city_name="广州", credential_valid=True, session_open=True, saved_at=now))
|
||||
session.add(NqiAccount(login_id="a2", city_name="深圳", credential_valid=False, session_open=False, saved_at=now - timedelta(days=2)))
|
||||
session.add(NqiAccount(login_id="a1", city_name="广州", credential_valid=True, session_open=True, created_at=now, saved_at=now))
|
||||
session.add(NqiAccount(login_id="a2", city_name="深圳", credential_valid=False, session_open=False, created_at=now - timedelta(days=2), saved_at=now - timedelta(days=2)))
|
||||
stats = client.get("/api/admin/dashboard", headers=headers).json()["pool"]
|
||||
assert stats["total"] == 2
|
||||
assert stats["valid"] == 1
|
||||
|
||||
@@ -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"
|
||||
Reference in New Issue
Block a user