chore: checkpoint current backend/runtime changes

This commit is contained in:
qzl
2026-03-06 17:28:17 +08:00
parent 2c59fe5ee2
commit b6087fd195
32 changed files with 1641 additions and 469 deletions
@@ -2,7 +2,7 @@ from __future__ import annotations
import pytest
from core.agent.infrastructure.queue.tasks import run_agent_task
from core.agent.infrastructure.queue.tasks import _build_redis_publisher, run_agent_task
class _FakeRunService:
@@ -67,3 +67,35 @@ async def test_run_agent_task_emits_error_event_on_exception() -> None:
)
assert events == ["RUN_STARTED", "RUN_ERROR"]
@pytest.mark.asyncio
async def test_run_agent_task_rejects_invalid_command() -> None:
with pytest.raises(ValueError, match="invalid command type"):
await run_agent_task({"command": "invalid", "session_id": "00000000-0000-0000-0000-000000000001"})
@pytest.mark.asyncio
async def test_run_agent_task_resume_requires_tool_call_id() -> None:
with pytest.raises(ValueError, match="tool_call_id is required"):
await run_agent_task(
{
"command": "resume",
"session_id": "00000000-0000-0000-0000-000000000001",
}
)
@pytest.mark.asyncio
async def test_build_redis_publisher_init_fail_raises_runtime_error(
monkeypatch: pytest.MonkeyPatch,
) -> None:
from core.agent.infrastructure.queue import tasks
async def _fake_get_client() -> object:
raise RuntimeError("Redis service initialization failed")
monkeypatch.setattr(tasks, "get_or_init_redis_client", _fake_get_client)
with pytest.raises(RuntimeError, match="Redis service initialization failed"):
await _build_redis_publisher()