refactor: 重构 schemas 结构,统一枚举定义
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from core.agentscope.schemas.consumer_registry import (
|
||||
AgentConsumerBinding,
|
||||
ConsumerRegistry,
|
||||
)
|
||||
from core.agentscope.schemas.pipeline_spec import ExecutorKind, PipelineSpec, StageSpec
|
||||
from schemas.agent.system_agent import AgentType
|
||||
|
||||
|
||||
def test_consumer_registry_rejects_duplicate_bits() -> None:
|
||||
with pytest.raises(ValueError, match="duplicate visibility bit"):
|
||||
ConsumerRegistry(
|
||||
bindings=[
|
||||
AgentConsumerBinding(agent_type="router", bit=16),
|
||||
AgentConsumerBinding(agent_type="worker", bit=16),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_pipeline_spec_requires_non_empty_stages() -> None:
|
||||
with pytest.raises(ValueError, match="at least 1 item"):
|
||||
PipelineSpec(mode="worker", stages=[])
|
||||
|
||||
|
||||
def test_stage_spec_normalizes_stage_name() -> None:
|
||||
spec = StageSpec(
|
||||
stage_name=" Worker ",
|
||||
agent_type=AgentType.WORKER,
|
||||
executor_kind=ExecutorKind.REACT,
|
||||
)
|
||||
|
||||
assert spec.stage_name == "worker"
|
||||
assert spec.agent_type == AgentType.WORKER
|
||||
@@ -2,23 +2,25 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from schemas.automation.config import AutomationJobConfig, default_memory_job_config
|
||||
from schemas.domain.automation import AutomationJobConfig
|
||||
from v1.auth.automation_static_config import load_static_automation_job_config
|
||||
|
||||
|
||||
def test_default_memory_job_config_has_expected_defaults() -> None:
|
||||
config = default_memory_job_config()
|
||||
def test_memory_extraction_static_config_has_expected_defaults() -> None:
|
||||
config = load_static_automation_job_config(config_name="memory_extraction")
|
||||
|
||||
assert config.agent_type.value == "memory"
|
||||
assert config.model_code == "qwen3.5-flash"
|
||||
assert "memory.write" in (config.enabled_tools or [])
|
||||
assert "memory.forget" in (config.enabled_tools or [])
|
||||
assert config.context is not None
|
||||
assert config.context.source.value == "latest_chat"
|
||||
assert config.schedule is not None
|
||||
assert config.schedule.type.value == "daily"
|
||||
|
||||
|
||||
def test_automation_job_config_rejects_non_flash_model() -> None:
|
||||
with pytest.raises(ValueError, match="model_code must be qwen3.5-flash"):
|
||||
def test_automation_job_config_rejects_missing_weekdays_for_weekly() -> None:
|
||||
with pytest.raises(ValueError, match="weekdays is required"):
|
||||
AutomationJobConfig.model_validate(
|
||||
{
|
||||
"agent_type": "memory",
|
||||
"model_code": "qwen-plus",
|
||||
"enabled_tools": ["calendar.read"],
|
||||
"input_template": "x",
|
||||
"context": {
|
||||
@@ -26,5 +28,9 @@ def test_automation_job_config_rejects_non_flash_model() -> None:
|
||||
"window_mode": "day",
|
||||
"window_count": 2,
|
||||
},
|
||||
"schedule": {
|
||||
"type": "weekly",
|
||||
"run_at": {"hour": 9, "minute": 0},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from datetime import UTC, datetime
|
||||
from uuid import uuid4
|
||||
|
||||
from schemas.messages.chat_message import AgentChatMessage
|
||||
from schemas.domain.chat_message import AgentChatMessage
|
||||
|
||||
|
||||
def test_agent_chat_message_schema_matches_messages_columns() -> None:
|
||||
|
||||
Reference in New Issue
Block a user