Exemplo n.º 1
0
    async def test_has_messages(self):
        await self.create_messages()

        request = await self.client.post(
            '/new-messages-number',
            data=personal_messages_pb2.NewMessagesNumberRequest(
                account_id=1).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.NewMessagesNumberResponse)
        self.assertEqual(data.number, 0)

        request = await self.client.post(
            '/new-messages-number',
            data=personal_messages_pb2.NewMessagesNumberRequest(
                account_id=2).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.NewMessagesNumberResponse)
        self.assertEqual(data.number, 1)

        request = await self.client.post(
            '/new-messages-number',
            data=personal_messages_pb2.NewMessagesNumberRequest(
                account_id=3).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.NewMessagesNumberResponse)
        self.assertEqual(data.number, 2)
Exemplo n.º 2
0
def new_messages_number(account_id):
    answer = tt_api.sync_request(
        url=conf.settings.TT_NEW_MESSAGES_NUMBER_URL,
        data=personal_messages_pb2.NewMessagesNumberRequest(
            account_id=account_id),
        AnswerType=personal_messages_pb2.NewMessagesNumberResponse)
    return answer.number