From 9b350132f4224a1173e1aa505a40bc852115958b Mon Sep 17 00:00:00 2001 From: huanghuoguoguo <60681390+huanghuoguoguo@users.noreply.github.com> Date: Sat, 17 Oct 2026 15:57:35 +0800 Subject: [PATCH] test(api): cover send delegation and reuse the prior list contract --- tests/integration/api/test_bots.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/integration/api/test_bots.py b/tests/integration/api/test_bots.py index 726a9c058..0f332bac5 100644 --- a/tests/integration/api/test_bots.py +++ b/tests/integration/api/test_bots.py @@ -199,7 +199,7 @@ class TestBotEndpoints: """Tests for /api/v1/platform/bots endpoints.""" @pytest.mark.asyncio - async def test_get_bots_success(self, quart_test_client, fake_bot_app): + async def test_get_bots_success(self, quart_test_client): """GET /api/v1/platform/bots returns bot list.""" response = await quart_test_client.get('/api/v1/platform/bots', headers={'Authorization': 'Bearer test_token'}) @@ -209,15 +209,6 @@ class TestBotEndpoints: assert 'data' in data assert 'bots' in data['data'] - called = fake_bot_app.bot_service.get_bots - assert called.await_count == 1 - assert called.await_args.args[0].workspace_uuid == 'workspace-test' - assert called.await_args.args[1:] == () - assert called.await_args.kwargs == {'include_secret': True} - assert data['data']['bots'] == [ - {'uuid': 'test-bot-uuid', 'name': 'Test Bot', 'platform': 'telegram', 'pipeline_uuid': 'test-pipeline-uuid'} - ] - @pytest.mark.asyncio async def test_create_bot_success(self, quart_test_client, fake_bot_app): """POST /api/v1/platform/bots creates new bot.""" @@ -422,7 +413,7 @@ class TestBotSendMessageEndpoint: """Tests for bot send message endpoint.""" @pytest.mark.asyncio - async def test_send_message_success(self, quart_test_client): + async def test_send_message_success(self, quart_test_client, fake_bot_app): """POST /api/v1/platform/bots/{uuid}/send_message sends message.""" response = await quart_test_client.post( '/api/v1/platform/bots/test-bot-uuid/send_message', @@ -439,6 +430,12 @@ class TestBotSendMessageEndpoint: assert data['code'] == 0 assert data['data']['sent'] is True + called = fake_bot_app.bot_service.send_message + called.assert_awaited_once() + assert called.await_args.args[0].workspace_uuid == 'workspace-test' + assert called.await_args.args[1:] == ('test-bot-uuid', 'person', 'user123', [{'type': 'text', 'text': 'Hello'}]) + assert called.await_args.kwargs == {} + @pytest.mark.asyncio async def test_send_message_missing_target_type(self, quart_test_client): """POST send_message without target_type returns 400."""