feat: 统一自动化任务调度配置并增强聊天流恢复
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, time, timezone
|
||||
from datetime import datetime, timezone
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
@@ -29,13 +29,24 @@ def _make_job_response(
|
||||
id=job_id or uuid4(),
|
||||
owner_id=owner_id or uuid4(),
|
||||
title=overrides.get("title", "Test Job"),
|
||||
schedule_type=overrides.get("schedule_type", "daily"),
|
||||
run_at=overrides.get("run_at", time(9, 0, 0)),
|
||||
timezone=overrides.get("timezone", "Asia/Shanghai"),
|
||||
status=overrides.get("status", "active"),
|
||||
is_system=overrides.get("is_system", False),
|
||||
config=overrides.get(
|
||||
"config", {"input_template": "Hello", "enabled_tools": [], "context": {}}
|
||||
"config",
|
||||
{
|
||||
"input_template": "Hello",
|
||||
"enabled_tools": [],
|
||||
"context": {
|
||||
"source": "latest_chat",
|
||||
"window_mode": "day",
|
||||
"window_count": 2,
|
||||
},
|
||||
"schedule": {
|
||||
"type": "daily",
|
||||
"run_at": {"hour": 9, "minute": 0},
|
||||
},
|
||||
},
|
||||
),
|
||||
next_run_at=overrides.get("next_run_at", now),
|
||||
created_at=overrides.get("created_at", now),
|
||||
@@ -104,13 +115,19 @@ def test_create_automation_job_requires_auth() -> None:
|
||||
"/api/v1/automation-jobs",
|
||||
json={
|
||||
"title": "New Job",
|
||||
"schedule_type": "daily",
|
||||
"run_at": "09:00:00",
|
||||
"timezone": "Asia/Shanghai",
|
||||
"config": {
|
||||
"input_template": "Hello",
|
||||
"enabled_tools": [],
|
||||
"context": {},
|
||||
"context": {
|
||||
"source": "latest_chat",
|
||||
"window_mode": "day",
|
||||
"window_count": 2,
|
||||
},
|
||||
"schedule": {
|
||||
"type": "daily",
|
||||
"run_at": {"hour": 9, "minute": 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -140,14 +157,20 @@ def test_create_automation_job_succeeds() -> None:
|
||||
"/api/v1/automation-jobs",
|
||||
json={
|
||||
"title": "New Job",
|
||||
"schedule_type": "daily",
|
||||
"run_at": "09:00:00",
|
||||
"timezone": "Asia/Shanghai",
|
||||
"status": "active",
|
||||
"config": {
|
||||
"input_template": "Hello",
|
||||
"enabled_tools": [],
|
||||
"context": {},
|
||||
"context": {
|
||||
"source": "latest_chat",
|
||||
"window_mode": "day",
|
||||
"window_count": 2,
|
||||
},
|
||||
"schedule": {
|
||||
"type": "daily",
|
||||
"run_at": {"hour": 9, "minute": 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -178,14 +201,20 @@ def test_create_automation_job_respects_limit() -> None:
|
||||
"/api/v1/automation-jobs",
|
||||
json={
|
||||
"title": "New Job",
|
||||
"schedule_type": "daily",
|
||||
"run_at": "09:00:00",
|
||||
"timezone": "Asia/Shanghai",
|
||||
"status": "active",
|
||||
"config": {
|
||||
"input_template": "Hello",
|
||||
"enabled_tools": [],
|
||||
"context": {},
|
||||
"context": {
|
||||
"source": "latest_chat",
|
||||
"window_mode": "day",
|
||||
"window_count": 2,
|
||||
},
|
||||
"schedule": {
|
||||
"type": "daily",
|
||||
"run_at": {"hour": 9, "minute": 0},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -204,7 +233,7 @@ def test_get_automation_job_requires_auth() -> None:
|
||||
def test_get_automation_job_returns_job() -> None:
|
||||
user_id = uuid4()
|
||||
job_id = uuid4()
|
||||
job = _make_job_response(id=job_id, owner_id=user_id)
|
||||
job = _make_job_response(job_id=job_id, owner_id=user_id)
|
||||
|
||||
captured_job_id = job_id
|
||||
captured_owner_id = user_id
|
||||
@@ -266,7 +295,11 @@ def test_update_automation_job_requires_auth() -> None:
|
||||
def test_update_automation_job_succeeds() -> None:
|
||||
user_id = uuid4()
|
||||
job_id = uuid4()
|
||||
updated_job = _make_job_response(id=job_id, owner_id=user_id, title="Updated Title")
|
||||
updated_job = _make_job_response(
|
||||
job_id=job_id,
|
||||
owner_id=user_id,
|
||||
title="Updated Title",
|
||||
)
|
||||
|
||||
class FakeService:
|
||||
async def update(
|
||||
|
||||
Reference in New Issue
Block a user