コード例 #1
0
    def test_add_participant_w_failed_participants(self):
        thread_id = "19:[email protected]"
        new_participant_id = "8:acs:57b9bac9-df6c-4d39-a73b-26e944adf6ea_9b0110-08007f1041"
        raised = False
        error_message = "some error message"

        def mock_send(*_, **__):
            return mock_response(status_code=201,
                                 json_payload={
                                     "errors": {
                                         "invalidParticipants": [{
                                             "code": "string",
                                             "message": error_message,
                                             "target": new_participant_id,
                                             "details": []
                                         }]
                                     }
                                 })

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

        new_participant = ChatThreadParticipant(
            user=CommunicationUserIdentifier(new_participant_id),
            display_name='name',
            share_history_time=datetime.utcnow())

        try:
            chat_thread_client.add_participant(new_participant)
        except:
            raised = True

        self.assertTrue(raised, 'Expected is no excpetion raised')
コード例 #2
0
 def add_participant(self):
     from azure.communication.chat import ChatThreadClient, CommunicationTokenCredential, \
         CommunicationTokenRefreshOptions
     refresh_options = CommunicationTokenRefreshOptions(self.token)
     chat_thread_client = ChatThreadClient(self.endpoint, CommunicationTokenCredential(refresh_options),
                                           self._thread_id)
     # [START add_participant]
     from azure.communication.chat import ChatThreadParticipant
     from datetime import datetime
     new_chat_thread_participant = ChatThreadParticipant(
             user=self.new_user,
             display_name='name',
             share_history_time=datetime.utcnow())
     chat_thread_client.add_participant(new_chat_thread_participant)
     # [END add_participant]
     print("add_chat_participant succeeded")
コード例 #3
0
    def test_add_participant(self):
        thread_id = "19:[email protected]"
        new_participant_id="8:acs:57b9bac9-df6c-4d39-a73b-26e944adf6ea_9b0110-08007f1041"
        raised = False

        def mock_send(*_, **__):
            return mock_response(status_code=201)
        chat_thread_client = ChatThreadClient("https://endpoint", TestChatThreadClient.credential, thread_id, transport=Mock(send=mock_send))

        new_participant = ChatThreadParticipant(
                user=CommunicationUserIdentifier(new_participant_id),
                display_name='name',
                share_history_time=datetime.utcnow())

        try:
            chat_thread_client.add_participant(new_participant)
        except:
            raised = True

        self.assertFalse(raised, 'Expected is no excpetion raised')