Download tests/unit/test_conductor.py from jayc1978/aegis: direct link, hf CLI and curl.
- Browser
- Download file 1.99 kB
-
https://huggingface.co/jayc1978/aegis/resolve/main/tests/unit/test_conductor.py
- Command line
-
hf download hf://jayc1978/aegis/tests/unit/test_conductor.py
-
curl -L -o test_conductor.py https://huggingface.co/jayc1978/aegis/resolve/main/tests/unit/test_conductor.py
1.99 kB
| import pytest | |
| from aegis.core import Agent, AgentContext, AgentResult, Task | |
| from aegis.core.conductor import Conductor | |
| from aegis.core.registry import AgentNotFoundError, AgentRegistry | |
| class StubAgent(Agent): | |
| def __init__( | |
| self, | |
| name: str, | |
| *, | |
| result_name: str | None = None, | |
| ) -> None: | |
| self.name = name | |
| self._result_name = result_name or name | |
| async def run(self, context: AgentContext) -> AgentResult: | |
| return AgentResult( | |
| agent_name=self._result_name, | |
| success=True, | |
| output={"task": context.task.name}, | |
| ) | |
| async def test_conductor_executes_registered_agent() -> None: | |
| registry = AgentRegistry([StubAgent("planner")]) | |
| conductor = Conductor(registry) | |
| context = AgentContext( | |
| task=Task( | |
| name="Create plan", | |
| description="Build a deterministic execution plan.", | |
| ) | |
| ) | |
| result = await conductor.execute("planner", context) | |
| assert result.success is True | |
| assert result.output == {"task": "Create plan"} | |
| async def test_conductor_rejects_missing_agent() -> None: | |
| conductor = Conductor(AgentRegistry()) | |
| context = AgentContext( | |
| task=Task( | |
| name="Missing agent", | |
| description="Verify missing-agent behavior.", | |
| ) | |
| ) | |
| with pytest.raises(AgentNotFoundError): | |
| await conductor.execute("missing", context) | |
| async def test_conductor_rejects_mismatched_result_name() -> None: | |
| registry = AgentRegistry([StubAgent("planner", result_name="research")]) | |
| conductor = Conductor(registry) | |
| context = AgentContext( | |
| task=Task( | |
| name="Validate result", | |
| description="Verify agent identity enforcement.", | |
| ) | |
| ) | |
| with pytest.raises( | |
| ValueError, | |
| match="Agent result name does not match", | |
| ): | |
| await conductor.execute("planner", context) | |