コード例 #1
0
    async def test_has_contacts(self):
        await self.create_messages()

        request = await self.client.post(
            '/get-contacts',
            data=personal_messages_pb2.GetContactsRequest(
                account_id=1).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.GetContactsResponse)
        self.assertCountEqual(data.accounts_ids, [2, 3])

        request = await self.client.post(
            '/get-contacts',
            data=personal_messages_pb2.GetContactsRequest(
                account_id=2).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.GetContactsResponse)
        self.assertCountEqual(data.accounts_ids, [1, 3])

        request = await self.client.post(
            '/get-contacts',
            data=personal_messages_pb2.GetContactsRequest(
                account_id=3).SerializeToString())
        data = await self.check_answer(
            request, personal_messages_pb2.GetContactsResponse)
        self.assertCountEqual(data.accounts_ids, [1, 2])
コード例 #2
0
 async def test_no_contacts(self):
     request = await self.client.post(
         '/get-contacts',
         data=personal_messages_pb2.GetContactsRequest(
             account_id=1).SerializeToString())
     data = await self.check_answer(
         request, personal_messages_pb2.GetContactsResponse)
     self.assertEqual(data.accounts_ids, [])
コード例 #3
0
def get_contacts(account_id):
    answer = tt_api.sync_request(url=conf.settings.TT_GET_CONTACTS_URL,
                                 data=personal_messages_pb2.GetContactsRequest(account_id=account_id),
                                 AnswerType=personal_messages_pb2.GetContactsResponse)
    return answer.accounts_ids