fix(bots): explain unavailable route tests

This commit is contained in:
RockChinQ
2026-08-25 22:03:57 +08:00
parent 792d961d28
commit 69ca7e21cd
7 changed files with 127 additions and 5 deletions
@@ -631,6 +631,46 @@ class TestBotServiceListEventRouteStatuses:
assert result['stale_routes'] == []
class TestBotServiceDispatchTestEventRoute:
"""Tests for dispatching a synthetic event through a saved route."""
async def test_returns_actionable_failure_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'})
service.list_event_route_statuses = AsyncMock(
return_value={
'routes': [],
'unmatched_events': [],
'stale_routes': [],
}
)
result = await service.dispatch_test_event_route(
WORKSPACE_UUID,
'bot-uuid',
'message.received',
{'message_text': 'Hello'},
)
assert result == {
'dispatched': False,
'event_type': 'message.received',
'failure_code': 'bot_runtime_unavailable',
'reason': 'Bot runtime is unavailable',
'suppressed_outputs': [],
'route_status': {
'routes': [],
'unmatched_events': [],
'stale_routes': [],
},
}
service.list_event_route_statuses.assert_awaited_once_with(WORKSPACE_UUID, 'bot-uuid')
class TestBotServiceSendMessage:
"""Tests for send_message method."""