mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-20 13:28:20 +02:00
Add test for msg to squeak entry (#1605)
This commit is contained in:
parent
9c3e63dd2e
commit
c8ac284749
2 changed files with 25 additions and 12 deletions
|
|
@ -208,20 +208,24 @@ def message_to_peer_address(peer_address: squeak_admin_pb2.PeerAddress) -> PeerA
|
|||
)
|
||||
|
||||
|
||||
def message_to_squeak_entry(squeak_entry: squeak_admin_pb2.SqueakDisplayEntry) -> SqueakEntry:
|
||||
def message_to_squeak_entry(squeak_entry_msg: squeak_admin_pb2.SqueakDisplayEntry) -> SqueakEntry:
|
||||
like_time_ms = squeak_entry_msg.liked_time_ms if squeak_entry_msg.liked_time_ms > 0 else None
|
||||
reply_to_hash = bytes.fromhex(
|
||||
squeak_entry_msg.reply_to) if squeak_entry_msg.reply_to else None
|
||||
content_str = squeak_entry_msg.content_str if len(
|
||||
squeak_entry_msg.content_str) > 0 else None
|
||||
return SqueakEntry(
|
||||
squeak_hash=bytes.fromhex(squeak_entry.squeak_hash),
|
||||
address=squeak_entry.author_address,
|
||||
block_height=squeak_entry.block_height,
|
||||
block_hash=bytes.fromhex(squeak_entry.block_hash),
|
||||
block_time=squeak_entry.block_time,
|
||||
squeak_time=squeak_entry.squeak_time,
|
||||
reply_to=bytes.fromhex(
|
||||
squeak_entry.reply_to) if squeak_entry.reply_to else None,
|
||||
is_unlocked=squeak_entry.is_unlocked,
|
||||
squeak_hash=bytes.fromhex(squeak_entry_msg.squeak_hash),
|
||||
address=squeak_entry_msg.author_address,
|
||||
block_height=squeak_entry_msg.block_height,
|
||||
block_hash=bytes.fromhex(squeak_entry_msg.block_hash),
|
||||
block_time=squeak_entry_msg.block_time,
|
||||
squeak_time=squeak_entry_msg.squeak_time,
|
||||
reply_to=reply_to_hash,
|
||||
is_unlocked=squeak_entry_msg.is_unlocked,
|
||||
squeak_profile=None, # TODO: message to squeak profile
|
||||
liked_time_ms=squeak_entry.liked_time_ms,
|
||||
content=squeak_entry.content_str,
|
||||
liked_time_ms=like_time_ms,
|
||||
content=content_str,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
from squeaknode.admin.messages import message_to_peer_address
|
||||
from squeaknode.admin.messages import message_to_squeak_entry
|
||||
from squeaknode.admin.messages import peer_address_to_message
|
||||
from squeaknode.admin.messages import received_offer_to_message
|
||||
from squeaknode.admin.messages import received_payment_to_message
|
||||
|
|
@ -49,6 +50,14 @@ def test_squeak_entry_to_message(squeak_entry_locked, squeak_entry_msg_locked):
|
|||
assert msg == squeak_entry_msg_locked
|
||||
|
||||
|
||||
def test_message_to_squeak_entry(squeak_entry_locked, squeak_entry_msg_locked):
|
||||
entry = message_to_squeak_entry(squeak_entry_msg_locked)
|
||||
|
||||
# TODO: remove this line after implementing "message_to_squeak_profile"
|
||||
entry_with_null_profile = squeak_entry_locked._replace(squeak_profile=None)
|
||||
assert entry == entry_with_null_profile
|
||||
|
||||
|
||||
def test_profile_to_message(signing_profile, signing_profile_msg):
|
||||
msg = squeak_profile_to_message(signing_profile)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue