コード例 #1
0
    def test_list_participants_with_results_per_page(self):
        thread_id = "19:[email protected]"
        participant_id_1 = "8:acs:9b665d53-8164-4923-ad5d-5e983b07d2e7_00000006-5399-552c-b274-5a3a0d0000dc"
        participant_id_2 = "8:acs:9b665d53-8164-4923-ad5d-5e983b07d2e7_00000006-9d32-35c9-557d-5a3a0d0002f1"
        raised = False

        def mock_send(*_, **__):
            return mock_response(status_code=200, json_payload={
                "value": [
                    {"id": participant_id_1},
                    {"id": participant_id_2}
                ]})

        chat_thread_client = ChatThreadClient("https://endpoint", TestChatThreadClient.credential, thread_id,
                                              transport=Mock(send=mock_send))

        chat_thread_participants = None
        try:
            chat_thread_participants = chat_thread_client.list_participants(results_per_page=2)
        except:
            raised = True

        self.assertFalse(raised, 'Expected is no excpetion raised')
        for chat_thread_participant_page in chat_thread_participants.by_page():
            l = list(chat_thread_participant_page)
            assert len(l) == 2
コード例 #2
0
 def list_participants(self):
     from azure.communication.chat import ChatThreadClient
     from azure.communication.chat import CommunicationTokenCredential, CommunicationTokenRefreshOptions
     refresh_options = CommunicationTokenRefreshOptions(self.token)
     chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(refresh_options), self._thread_id)
     # [START list_participants]
     chat_thread_participants = chat_thread_client.list_participants()
     print("list_chat_participants succeeded, participants: ")
     for chat_thread_participant in chat_thread_participants:
         print(chat_thread_participant)
コード例 #3
0
    def test_list_participants(self):
        thread_id = "19:[email protected]"
        participant_id="8:acs:57b9bac9-df6c-4d39-a73b-26e944adf6ea_9b0110-08007f1041"
        raised = False

        def mock_send(*_, **__):
            return mock_response(status_code=200, json_payload={"value": [{"id": participant_id}]})
        chat_thread_client = ChatThreadClient("https://endpoint", TestChatThreadClient.credential, thread_id, transport=Mock(send=mock_send))

        chat_thread_participants = None
        try:
            chat_thread_participants = chat_thread_client.list_participants()
        except:
            raised = True

        self.assertFalse(raised, 'Expected is no excpetion raised')
        for chat_thread_participant_page in chat_thread_participants.by_page():
            l = list(chat_thread_participant_page)
            assert len(l) == 1
            l[0].user.id = participant_id
コード例 #4
0
    def test_list_participants(self):
        thread_id = "19:[email protected]"
        participant_id = "8:acs:57b9bac9-df6c-4d39-a73b-26e944adf6ea_9b0110-08007f1041"
        raised = False

        def mock_send(*_, **__):
            return mock_response(status_code=200,
                                 json_payload={
                                     "value": [{
                                         "communicationIdentifier": {
                                             "rawId": participant_id,
                                             "communicationUser": {
                                                 "id": participant_id
                                             }
                                         },
                                         "displayName":
                                         "Bob",
                                         "shareHistoryTime":
                                         "2020-10-30T10:50:50Z"
                                     }]
                                 })

        chat_thread_client = ChatThreadClient("https://endpoint",
                                              TestChatThreadClient.credential,
                                              thread_id,
                                              transport=Mock(send=mock_send))

        chat_thread_participants = None
        try:
            chat_thread_participants = chat_thread_client.list_participants()
        except:
            raised = True

        self.assertFalse(raised, 'Expected is no excpetion raised')
        for chat_thread_participant_page in chat_thread_participants.by_page():
            l = list(chat_thread_participant_page)
            assert len(l) == 1
            l[0].identifier.properties['id'] = participant_id