You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_routed_agent.py 820 B

123456789101112131415161718192021222324
  1. from dataclasses import dataclass
  2. import pytest
  3. import logging
  4. from agnext.application import SingleThreadedAgentRuntime
  5. from agnext.components import TypeSubscription
  6. from agnext.core import TopicId
  7. from test_utils import LoopbackAgent
  8. @dataclass
  9. class UnhandledMessageType: ...
  10. @pytest.mark.asyncio
  11. async def test_routed_agent(caplog: pytest.LogCaptureFixture) -> None:
  12. runtime = SingleThreadedAgentRuntime()
  13. with caplog.at_level(logging.INFO):
  14. await runtime.register("loopback", lambda: LoopbackAgent(), lambda: [TypeSubscription("default", "loopback")])
  15. runtime.start()
  16. await runtime.publish_message(UnhandledMessageType(), topic_id=TopicId("default", "default"))
  17. await runtime.stop_when_idle()
  18. assert any("Unhandled message: " in e.message for e in caplog.records)