2026-03-19 18:42:35 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2026-03-22 20:35:55 +08:00
|
|
|
from core.agentscope.schemas.consumer_registry import (
|
|
|
|
|
AgentConsumerBinding,
|
|
|
|
|
ConsumerRegistry,
|
2026-03-19 18:42:35 +08:00
|
|
|
)
|
2026-03-22 20:35:55 +08:00
|
|
|
from core.agentscope.schemas.pipeline_spec import ExecutorKind, PipelineSpec, StageSpec
|
|
|
|
|
from schemas.agent.system_agent import AgentType
|
2026-03-19 18:42:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ",
|
2026-03-22 20:35:55 +08:00
|
|
|
agent_type=AgentType.WORKER,
|
2026-03-19 18:42:35 +08:00
|
|
|
executor_kind=ExecutorKind.REACT,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert spec.stage_name == "worker"
|
2026-03-22 20:35:55 +08:00
|
|
|
assert spec.agent_type == AgentType.WORKER
|