fix(bots): simplify event routing status

This commit is contained in:
RockChinQ
2026-08-25 21:18:01 +08:00
parent 6a6a2b865b
commit 68620c4572
7 changed files with 151 additions and 84 deletions
@@ -62,9 +62,7 @@ def _set_discovered_adapters(ap, *webhook_adapters: str) -> None:
)
for adapter_name in webhook_adapters
]
ap.discover = SimpleNamespace(
get_components_by_kind=Mock(return_value=components)
)
ap.discover = SimpleNamespace(get_components_by_kind=Mock(return_value=components))
class TestBotServiceGetBots:
@@ -583,6 +581,56 @@ class TestBotServiceListEventLogs:
assert total == 5
class TestBotServiceListEventRouteStatuses:
"""Tests for event route status when a persisted Bot is not running."""
async def test_returns_saved_routes_when_runtime_bot_is_unavailable(self):
ap = SimpleNamespace()
ap.platform_mgr = SimpleNamespace()
ap.platform_mgr.get_bot_by_uuid = AsyncMock(return_value=None)
service = BotService(ap)
service.get_bot = AsyncMock(
return_value={
'uuid': 'bot-uuid',
'event_bindings': [
{
'id': 'binding-1',
'event_pattern': 'message.received',
'target_type': 'agent',
'target_uuid': 'agent-1',
'enabled': True,
}
],
}
)
result = await service.list_event_route_statuses(WORKSPACE_UUID, 'bot-uuid')
assert result['routes'] == [
{
'binding_id': 'binding-1',
'event_pattern': 'message.received',
'event_type': None,
'target_type': 'agent',
'target_uuid': 'agent-1',
'last_status': None,
'failure_code': None,
'reason': None,
'run_id': None,
'timestamp': None,
'seq_id': None,
'level': None,
'message': '',
'order': 0,
'enabled': True,
'current': True,
}
]
assert result['unmatched_events'] == []
assert result['stale_routes'] == []
class TestBotServiceSendMessage:
"""Tests for send_message method."""