mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
Add core components for topics (#278)
* Add core components for topics * rename topic to topic id
This commit is contained in:
22
python/tests/test_subscription.py
Normal file
22
python/tests/test_subscription.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from agnext.components import TypeSubscription
|
||||
from agnext.core import TopicId, AgentId
|
||||
|
||||
import pytest
|
||||
|
||||
from agnext.core.exceptions import CantHandleException
|
||||
|
||||
def test_type_subscription_match() -> None:
|
||||
sub = TypeSubscription(topic_type="t1", agent_type="a1")
|
||||
|
||||
assert sub.is_match(TopicId(type="t0", source="s1")) == False
|
||||
assert sub.is_match(TopicId(type="t1", source="s1")) == True
|
||||
assert sub.is_match(TopicId(type="t1", source="s2")) == True
|
||||
|
||||
|
||||
def test_type_subscription_map() -> None:
|
||||
sub = TypeSubscription(topic_type="t1", agent_type="a1")
|
||||
|
||||
assert sub.map_to_agent(TopicId(type="t1", source="s1")) == AgentId(name="a1", namespace="s1")
|
||||
|
||||
with pytest.raises(CantHandleException):
|
||||
_agent_id = sub.map_to_agent(TopicId(type="t0", source="s1"))
|
||||
Reference in New Issue
Block a user