33import pytest
44
55from mpt_api_client .exceptions import MPTAPIError
6+ from mpt_api_client .models import ModelCollection
67from mpt_api_client .resources .helpdesk .chat_participants import ChatParticipant
78
89pytestmark = [pytest .mark .flaky ]
@@ -15,30 +16,35 @@ async def test_list_chat_participants(async_chat_participants_service):
1516 assert all (isinstance (participant , ChatParticipant ) for participant in result )
1617
1718
18- @pytest .mark .skip (reason = "Unskip after MPT-20015 completed" ) # noqa: AAA01
19- def test_create_chat_participant (async_created_chat_participant ):
20- assert isinstance (async_created_chat_participant , ChatParticipant )
19+ def test_create_chat_participant (async_created_chat_participant , contact_id ): # noqa: AAA01
20+ assert isinstance (async_created_chat_participant , ModelCollection )
21+ assert all (isinstance (cp , ChatParticipant ) for cp in async_created_chat_participant )
22+ chat_participants_list = async_created_chat_participant .to_list ()
23+ assert any (cp ["contact" ]["id" ] == contact_id for cp in chat_participants_list )
2124
2225
23- @pytest .mark .skip (reason = "Unskip after MPT-20015 completed" )
2426async def test_update_chat_participant (
2527 async_chat_participants_service , async_created_chat_participant
2628):
27- result = await async_chat_participants_service .update (
28- async_created_chat_participant .id ,
29- {"status" : "Active" },
30- )
29+ chat_participant = async_created_chat_participant [0 ].to_dict ()
30+ new_muted_status = not chat_participant ["muted" ]
31+ chat_participant ["muted" ] = new_muted_status
32+
33+ result = await async_chat_participants_service .update (chat_participant ["id" ], chat_participant )
3134
32- assert isinstance ( result , ChatParticipant )
35+ assert result . to_dict (). get ( "muted" ) == new_muted_status
3336
3437
35- @pytest .mark .skip (reason = "Unskip after MPT-20015 completed" )
3638async def test_delete_chat_participant (
37- async_chat_participants_service , async_created_chat_participant
39+ async_chat_participants_service , async_created_chat_participant , contact_id
3840):
39- result = async_created_chat_participant
41+ result = next (
42+ chat_participant
43+ for chat_participant in async_created_chat_participant .to_list ()
44+ if chat_participant ["contact" ]["id" ] == contact_id
45+ )
4046
41- await async_chat_participants_service .delete (result . id )
47+ await async_chat_participants_service .delete (result [ "id" ] )
4248
4349
4450async def test_update_chat_participant_not_found (
0 commit comments