예제 #1
0
    def test_add_members(self):
        thread_id = "19:[email protected]"
        new_member_id = "8:acs:57b9bac9-df6c-4d39-a73b-26e944adf6ea_9b0110-08007f1041"
        raised = False

        def mock_send(*_, **__):
            return mock_response(status_code=207)

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

        new_member = ChatThreadMember(
            user=CommunicationUserIdentifier(new_member_id),
            display_name='name',
            share_history_time=datetime.utcnow())
        members = [new_member]

        try:
            chat_thread_client.add_members(members)
        except:
            raised = True

        self.assertFalse(raised, 'Expected is no excpetion raised')
예제 #2
0
    def add_members(self):
        from azure.communication.chat import ChatThreadClient, CommunicationUserCredential
        chat_thread_client = ChatThreadClient(
            self.endpoint, CommunicationUserCredential(self.token),
            self._thread_id)

        # [START add_members]
        from azure.communication.chat import ChatThreadMember
        from datetime import datetime
        new_member = ChatThreadMember(user=self.new_user,
                                      display_name='name',
                                      share_history_time=datetime.utcnow())
        thread_members = [new_member]
        chat_thread_client.add_members(thread_members)
        # [END add_members]
        print("add_chat_members succeeded")