|
| 1 | +import pytest |
| 2 | + |
| 3 | +from mpt_api_client.exceptions import MPTAPIError |
| 4 | + |
| 5 | +pytestmark = [pytest.mark.flaky] |
| 6 | + |
| 7 | + |
| 8 | +async def test_list_chat_messages(async_chat_messages_service): |
| 9 | + result = await async_chat_messages_service.fetch_page(limit=1) |
| 10 | + |
| 11 | + assert len(result) > 0 |
| 12 | + |
| 13 | + |
| 14 | +def test_create_chat_message(async_created_chat_message, chat_message_data): # noqa: AAA01 |
| 15 | + assert async_created_chat_message.id is not None |
| 16 | + assert async_created_chat_message.to_dict().get("content") == chat_message_data["content"] |
| 17 | + |
| 18 | + |
| 19 | +async def test_update_chat_message_visibility( |
| 20 | + async_chat_messages_service, async_created_chat_message |
| 21 | +): |
| 22 | + result = await async_chat_messages_service.update( |
| 23 | + async_created_chat_message.id, |
| 24 | + {"visibility": "Public"}, |
| 25 | + ) |
| 26 | + |
| 27 | + assert result.id == async_created_chat_message.id |
| 28 | + |
| 29 | + |
| 30 | +async def test_delete_chat_message(async_chat_messages_service, async_created_chat_message): |
| 31 | + result = async_created_chat_message |
| 32 | + |
| 33 | + await async_chat_messages_service.delete(result.id) |
| 34 | + |
| 35 | + |
| 36 | +async def test_update_chat_message_not_found(async_chat_messages_service, invalid_chat_message_id): |
| 37 | + with pytest.raises(MPTAPIError, match=r"404 Not Found"): |
| 38 | + await async_chat_messages_service.update( |
| 39 | + invalid_chat_message_id, |
| 40 | + {"visibility": "Public"}, |
| 41 | + ) |
| 42 | + |
| 43 | + |
| 44 | +async def test_delete_chat_message_not_found(async_chat_messages_service, invalid_chat_message_id): |
| 45 | + with pytest.raises(MPTAPIError, match=r"404 Not Found"): |
| 46 | + await async_chat_messages_service.delete(invalid_chat_message_id) |
0 commit comments