mirror of
https://github.com/microsoft/autogen.git
synced 2026-02-12 11:25:30 -05:00
ensure agent name is unique, add some docs (#26)
This commit is contained in:
32
tests/test_runtime.py
Normal file
32
tests/test_runtime.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from typing import Any, Sequence
|
||||
import pytest
|
||||
|
||||
from agnext.application_components.single_threaded_agent_runtime import SingleThreadedAgentRuntime
|
||||
from agnext.core.agent_runtime import AgentRuntime
|
||||
from agnext.core.base_agent import BaseAgent
|
||||
from agnext.core.cancellation_token import CancellationToken
|
||||
|
||||
class NoopAgent(BaseAgent):
|
||||
def __init__(self, name: str, router: AgentRuntime) -> None:
|
||||
super().__init__(name, router)
|
||||
|
||||
@property
|
||||
def subscriptions(self) -> Sequence[type]:
|
||||
return []
|
||||
|
||||
async def on_message(self, message: Any, cancellation_token: CancellationToken) -> Any:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_agent_names_must_be_unique() -> None:
|
||||
router = SingleThreadedAgentRuntime()
|
||||
|
||||
_agent1 = NoopAgent("name1", router)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
_agent1_again = NoopAgent("name1", router)
|
||||
|
||||
_agent3 = NoopAgent("name3", router)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user