def handle_get_reply_squeak_display_entries(self, request):
     squeak_hash_str = request.squeak_hash
     squeak_hash = bytes.fromhex(squeak_hash_str)
     limit = request.limit
     last_entry = message_to_squeak_entry(
         request.last_entry) if request.HasField("last_entry") else None
     logger.info(
         """Handle get reply squeak display entries for squeak hash: {} with
     limit: {}
     last_entry: {}
     """.format(
             squeak_hash_str,
             limit,
             last_entry,
         ))
     squeak_entries = (self.squeak_controller.get_reply_squeak_entries(
         squeak_hash,
         limit,
         last_entry,
     ))
     logger.info("Got number of reply squeak entries: {}".format(
         len(squeak_entries)))
     squeak_display_msgs = [
         squeak_entry_to_message(entry) for entry in squeak_entries
     ]
     return squeak_admin_pb2.GetReplySqueakDisplaysReply(
         squeak_display_entries=squeak_display_msgs)
 def handle_get_squeak_display_entries_for_text_search(self, request):
     search_text = request.search_text
     limit = request.limit
     last_entry = message_to_squeak_entry(
         request.last_entry) if request.HasField("last_entry") else None
     logger.info(
         """Handle get squeak display entries for search_text: {} with
     limit: {}
     last_entry: {}
     """.format(
             search_text,
             limit,
             last_entry,
         ))
     squeak_entries = (
         self.squeak_controller.get_squeak_entries_for_text_search(
             search_text,
             limit,
             last_entry,
         ))
     logger.info("Got number of squeak entries for text search: {}".format(
         len(squeak_entries)))
     squeak_display_msgs = [
         squeak_entry_to_message(entry) for entry in squeak_entries
     ]
     return squeak_admin_pb2.GetAddressSqueakDisplaysReply(
         squeak_display_entries=squeak_display_msgs)
 def handle_get_ancestor_squeak_display_entries(self, request):
     squeak_hash_str = request.squeak_hash
     squeak_hash = bytes.fromhex(squeak_hash_str)
     logger.info(
         "Handle get ancestor squeak display entries for squeak hash: {}".
         format(squeak_hash_str))
     squeak_entries = (self.squeak_controller.get_ancestor_squeak_entries(
         squeak_hash, ))
     logger.info("Got number of ancestor squeak entries: {}".format(
         len(squeak_entries)))
     squeak_display_msgs = [
         squeak_entry_to_message(entry) for entry in squeak_entries
     ]
     return squeak_admin_pb2.GetAncestorSqueakDisplaysReply(
         squeak_display_entries=squeak_display_msgs)
 def handle_subscribe_ancestor_squeak_displays(self, request, stopped):
     squeak_hash_str = request.squeak_hash
     squeak_hash = bytes.fromhex(squeak_hash_str)
     logger.info(
         "Handle subscribe ancestor squeak displays for hash: {}".format(
             squeak_hash_str))
     squeak_entries_stream = self.squeak_controller.subscribe_squeak_ancestor_entries(
         squeak_hash,
         stopped,
     )
     for squeak_entries in squeak_entries_stream:
         logger.info("Got number of ancestor squeak entries: {}".format(
             len(squeak_entries)))
         squeak_display_msgs = [
             squeak_entry_to_message(entry) for entry in squeak_entries
         ]
         yield squeak_admin_pb2.GetAncestorSqueakDisplaysReply(
             squeak_display_entries=squeak_display_msgs)
 def handle_get_liked_squeak_display_entries(self, request):
     limit = request.limit
     last_entry = message_to_squeak_entry(
         request.last_entry) if request.HasField("last_entry") else None
     logger.info("""Handle get liked squeak display entries with
     limit: {}
     last_entry: {}
     """.format(
         limit,
         last_entry,
     ))
     squeak_entries = (self.squeak_controller.get_liked_squeak_entries(
         limit,
         last_entry,
     ))
     logger.info("Got number of liked squeak entries: {}".format(
         len(squeak_entries)))
     squeak_display_msgs = [
         squeak_entry_to_message(entry) for entry in squeak_entries
     ]
     return squeak_admin_pb2.GetLikedSqueakDisplaysReply(
         squeak_display_entries=squeak_display_msgs)
Exemple #6
0
def test_squeak_entry_to_message(squeak_entry_locked, squeak_entry_msg_locked):
    msg = squeak_entry_to_message(squeak_entry_locked)

    assert msg == squeak_entry_msg_locked