37 lines
1,006 B
Python
37 lines
1,006 B
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from adapter.matrix.agent_registry import AgentRegistryError, load_agent_registry
|
|
|
|
|
|
def test_load_agent_registry_reads_yaml_entries(tmp_path: Path):
|
|
path = tmp_path / "agents.yaml"
|
|
path.write_text(
|
|
"agents:\n"
|
|
" - id: agent-1\n"
|
|
" label: Analyst\n"
|
|
" - id: agent-2\n"
|
|
" label: Research\n",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
registry = load_agent_registry(path)
|
|
|
|
assert [agent.agent_id for agent in registry.agents] == ["agent-1", "agent-2"]
|
|
assert registry.get("agent-1").label == "Analyst"
|
|
|
|
|
|
def test_load_agent_registry_rejects_duplicate_ids(tmp_path: Path):
|
|
path = tmp_path / "agents.yaml"
|
|
path.write_text(
|
|
"agents:\n"
|
|
" - id: agent-1\n"
|
|
" label: Analyst\n"
|
|
" - id: agent-1\n"
|
|
" label: Duplicate\n",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
with pytest.raises(AgentRegistryError, match="duplicate agent id"):
|
|
load_agent_registry(path)
|