feat(settings): 保存超级编导账号/密码后立刻重试自动追加
Deploy VitePress site to Pages / build (push) Canceled after 0s
Deploy VitePress site to Pages / Deploy (push) Canceled after 0s

填好凭据还要等两个小时才生效没道理。保存 superdir_username/password/token
时,把抖音作品任务的自动追加调度钟挪到现在,下一个 tick 就用新凭据续期。
This commit is contained in:
2026-10-25 11:10:06 +08:00
parent d30ccb196a
commit b05491e9de
2 changed files with 64 additions and 1 deletions
+38
View File
@@ -28,6 +28,7 @@ from api.main import app
from api.monitor import app_settings, db as monitor_db
from api.monitor import scheduler as scheduler_module
from api.monitor.scheduler import MonitorScheduler
from api.monitor.models import MonitorTask
from api.monitor.settings import get_setting
SECRET_VALUE = "web_session=SUPERSECRET; a1=abc"
@@ -75,6 +76,43 @@ class TestReadSettings:
class TestUpdateSettings:
@pytest.mark.asyncio
async def test_saving_superdir_credentials_retries_auto_append_now(self, client):
"""填好账号密码之后不该再等一个间隔才生效 —— 下一 tick 就试着续期。"""
async with monitor_db.get_session() as session:
task = MonitorTask(
name="自动追加",
platform="dy",
mode="note",
enabled=True,
interval_minutes=360,
max_notes_count=20,
enable_comments=False,
max_comments_count=50,
run_timeout_seconds=3600,
superdir_auto_enabled=True,
superdir_auto_interval_minutes=120,
superdir_auto_next_at=9_999_999_999_999,
superdir_auto_last_error="token 失效",
created_at=0,
updated_at=0,
)
session.add(task)
await session.flush()
task_id = task.id
await client.put(
"/api/settings",
params={"platform": "dy"},
json={"platform.dy.superdir_username": "15655035256"},
)
async with monitor_db.get_session() as session:
task = await session.get(MonitorTask, task_id)
assert task.superdir_auto_next_at < 9_999_999_999_999
assert task.superdir_auto_last_error == ""
@pytest.mark.asyncio
async def test_partial_update_leaves_other_keys_alone(self, client):
await client.put(