|
20 | 20 | ListTasksRequest, |
21 | 21 | Message, |
22 | 22 | Role, |
| 23 | + SendMessageConfiguration, |
23 | 24 | SendMessageRequest, |
24 | 25 | SendMessageResponse, |
25 | 26 | StreamResponse, |
@@ -625,6 +626,50 @@ async def mock_send_request(*args, **kwargs): |
625 | 626 | assert response == SendMessageResponse() |
626 | 627 |
|
627 | 628 |
|
| 629 | +@pytest.mark.asyncio |
| 630 | +async def test_compat_rest_transport_send_message_without_configuration( |
| 631 | + transport, |
| 632 | +): |
| 633 | + """No configuration is sent, so the server keeps its blocking default.""" |
| 634 | + sent: dict = {} |
| 635 | + |
| 636 | + async def mock_execute_request(method, path, context=None, json=None): |
| 637 | + sent.update(json) |
| 638 | + return {} |
| 639 | + |
| 640 | + transport._execute_request = mock_execute_request |
| 641 | + |
| 642 | + req = SendMessageRequest( |
| 643 | + message=Message(message_id='msg-1', role=Role.ROLE_USER) |
| 644 | + ) |
| 645 | + await transport.send_message(req) |
| 646 | + |
| 647 | + assert 'configuration' not in sent |
| 648 | + |
| 649 | + |
| 650 | +@pytest.mark.asyncio |
| 651 | +async def test_compat_rest_transport_send_message_with_configuration( |
| 652 | + transport, |
| 653 | +): |
| 654 | + sent: dict = {} |
| 655 | + |
| 656 | + async def mock_execute_request(method, path, context=None, json=None): |
| 657 | + sent.update(json) |
| 658 | + return {} |
| 659 | + |
| 660 | + transport._execute_request = mock_execute_request |
| 661 | + |
| 662 | + req = SendMessageRequest( |
| 663 | + message=Message(message_id='msg-1', role=Role.ROLE_USER), |
| 664 | + configuration=SendMessageConfiguration( |
| 665 | + accepted_output_modes=['text/plain'] |
| 666 | + ), |
| 667 | + ) |
| 668 | + await transport.send_message(req) |
| 669 | + |
| 670 | + assert sent['configuration']['blocking'] is True |
| 671 | + |
| 672 | + |
628 | 673 | @pytest.mark.asyncio |
629 | 674 | async def test_compat_rest_transport_get_task_no_history(transport): |
630 | 675 | async def mock_execute_request(method, path, context=None, params=None): |
|
0 commit comments