Esempio n. 1
0
    async def test_reversed(self):
        await self.prepair_data()
        request = await self.client.post(
            '/get-conversation',
            data=personal_messages_pb2.GetConversationRequest(
                account_id=1, partner_id=2, text=None, offset=None,
                limit=None).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.GetConversationResponse)

        self.assertEqual(data.total, 3)
        self.assertEqual(
            list(data.messages), await load_protocol_messages_by_bodies(
                ['message 5', 'message 4', 'message 1']))

        request = await self.client.post(
            '/get-conversation',
            data=personal_messages_pb2.GetConversationRequest(
                account_id=2, partner_id=1, text=None, offset=None,
                limit=None).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.GetConversationResponse)

        self.assertEqual(data.total, 3)
        self.assertEqual(
            list(data.messages), await load_protocol_messages_by_bodies(
                ['message 5', 'message 4', 'message 1']))
Esempio n. 2
0
def get_conversation(account_id, partner_id, text=None, offset=None, limit=None):
    data = personal_messages_pb2.GetConversationRequest(account_id=account_id,
                                                        partner_id=partner_id,
                                                        text=text,
                                                        offset=offset,
                                                        limit=limit)

    answer = tt_api.sync_request(url=conf.settings.TT_GET_CONVERSATION_URL,
                                 data=data,
                                 AnswerType=personal_messages_pb2.GetConversationResponse)

    return answer.total, answer.messages
Esempio n. 3
0
    async def test_no_messages(self):
        await self.prepair_data()
        request = await self.client.post(
            '/get-conversation',
            data=personal_messages_pb2.GetConversationRequest(
                account_id=666,
                partner_id=1,
                text=None,
                offset=None,
                limit=None).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.GetConversationResponse)

        self.assertEqual(data.total, 0)
        self.assertEqual(list(data.messages), [])