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