コード例 #1
0
ファイル: test_handlers.py プロジェクト: warkb/the-tale
    async def test_version__update(self):
        request = await self.client.post(
            '/push-message',
            data=diary_pb2.PushMessageRequest(
                account_id=1, message=diary_pb2.Message(),
                diary_size=100).SerializeToString())
        await self.check_answer(request, diary_pb2.PushMessageResponse)

        request = await self.client.post(
            '/version',
            data=diary_pb2.VersionRequest(account_id=1).SerializeToString())
        data_1 = await self.check_answer(request, diary_pb2.VersionResponse)

        request = await self.client.post(
            '/push-message',
            data=diary_pb2.PushMessageRequest(
                account_id=1, message=diary_pb2.Message(),
                diary_size=100).SerializeToString())
        await self.check_answer(request, diary_pb2.PushMessageResponse)

        request = await self.client.post(
            '/version',
            data=diary_pb2.VersionRequest(account_id=1).SerializeToString())
        data_2 = await self.check_answer(request, diary_pb2.VersionResponse)

        self.assertGreater(data_2.version, data_1.version)
コード例 #2
0
ファイル: protobuf.py プロジェクト: warkb/the-tale
def from_message(message):
    return diary_pb2.Message(timestamp=message.timestamp,
                             turn_number=message.turn_number,
                             type=message.type,
                             game_time=message.game_time,
                             game_date=message.game_date,
                             position=message.position,
                             message=message.message,
                             variables=message.variables)
コード例 #3
0
ファイル: tt_api.py プロジェクト: serhii73/the-tale
def push_message_to_diary(account_id, message, is_premium):
    diary_size = conf.heroes_settings.DIARY_LOG_LENGTH_PREMIUM if is_premium else conf.heroes_settings.DIARY_LOG_LENGTH

    game_time = message.game_time()

    diary_message = diary_pb2.Message(timestamp=message.timestamp,
                                      turn_number=message.turn_number,
                                      type=message.key.value if message.key else None,
                                      game_time=game_time.time.verbose(),
                                      game_date=game_time.date.verbose_full(),
                                      position=message.position,
                                      message=message.message,
                                      variables=message.get_variables())

    tt_api.async_request(url=conf.heroes_settings.DIARY_PUSH_MESSAGE_URL,
                         data=diary_pb2.PushMessageRequest(account_id=account_id,
                                                           message=diary_message,
                                                           diary_size=diary_size))