Ejemplo n.º 1
0
    def test_list_read_receipts(self):
        thread_id = "19:[email protected]"
        message_id = "1596823919339"
        raised = False

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

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

        read_receipts = None
        try:
            read_receipts = chat_thread_client.list_read_receipts()
        except:
            raised = True

        self.assertFalse(raised, 'Expected is no excpetion raised')
        for read_receipt_page in read_receipts.by_page():
            l = list(read_receipt_page)
            assert len(l) == 1
Ejemplo n.º 2
0
 def list_read_receipts(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_read_receipts]
     read_receipts = chat_thread_client.list_read_receipts()
     print("list_read_receipts succeeded, receipts:")
     for read_receipt in read_receipts:
         print(read_receipt)
Ejemplo n.º 3
0
 def list_read_receipts(self):
     from azure.communication.chat import ChatThreadClient
     from azure.communication.chat import CommunicationUserCredential
     chat_thread_client = ChatThreadClient(
         self.endpoint, CommunicationUserCredential(self.token),
         self._thread_id)
     # [START list_read_receipts]
     read_receipts = chat_thread_client.list_read_receipts()
     print("list_read_receipts succeeded, receipts:")
     for read_receipt in read_receipts:
         print(read_receipt)
    def test_list_read_receipts_with_results_per_page(self):
        thread_id = "19:[email protected]"
        message_id_1 = "1596823919339"
        message_id_2 = "1596823919340"
        raised = False

        def mock_send(*_, **__):
            return mock_response(status_code=200,
                                 json_payload={
                                     "value": [{
                                         "chatMessageId": message_id_1,
                                         "senderCommunicationIdentifier": {
                                             "rawId": "string",
                                             "communicationUser": {
                                                 "id": "string"
                                             }
                                         }
                                     }, {
                                         "chatMessageId": message_id_2,
                                         "senderCommunicationIdentifier": {
                                             "rawId": "string",
                                             "communicationUser": {
                                                 "id": "string"
                                             }
                                         }
                                     }]
                                 })

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

        read_receipts = None
        try:
            read_receipts = chat_thread_client.list_read_receipts(
                results_per_page=2)
        except:
            raised = True

        self.assertFalse(raised, 'Expected is no excpetion raised')
        for read_receipt_page in read_receipts.by_page():
            l = list(read_receipt_page)
            assert len(l) == 2