Added undeleteMessage function in helper_inbox & respective method in api.py and separated inbox & trash testcases

This commit is contained in:
kuldeep.k@cisinlabs.com 2021-11-30 19:46:18 +05:30
parent 16175278a8
commit 5771f21cfb
No known key found for this signature in database
GPG Key ID: AF4FB299BF7C7C2A
3 changed files with 28 additions and 3 deletions

View File

@ -1459,6 +1459,13 @@ class BMRPCDispatcher(object):
return None return None
return data return data
@testmode('undeleteMessage')
def HandleUndeleteMessage(self, msgid):
"""Undelete message"""
msgid = self._decode(msgid, "hex")
helper_inbox.undeleteMessage(msgid)
return "Undeleted message"
@command('deleteAndVacuum') @command('deleteAndVacuum')
def HandleDeleteAndVacuum(self): def HandleDeleteAndVacuum(self):
"""Cleanup trashes and vacuum messages database""" """Cleanup trashes and vacuum messages database"""

View File

@ -18,6 +18,11 @@ def trash(msgid):
queues.UISignalQueue.put(('removeInboxRowByMsgid', msgid)) queues.UISignalQueue.put(('removeInboxRowByMsgid', msgid))
def undeleteMessage(msgid):
"""Undelte the message"""
sqlExecute('''UPDATE inbox SET folder='inbox' WHERE msgid=?''', msgid)
def isMessageAlreadyInInbox(sigHash): def isMessageAlreadyInInbox(sigHash):
"""Check for previous instances of this message""" """Check for previous instances of this message"""
queryReturn = sqlQuery( queryReturn = sqlQuery(

View File

@ -97,9 +97,8 @@ class TestAPI(TestAPIProto):
sample_statusbar_msg sample_statusbar_msg
) )
def test_message_inbox_and_trash(self): def test_message_inbox(self):
"""Test message inbox methods""" """Test message inbox methods"""
# Inbox function related tests
self.assertEqual( self.assertEqual(
len(json.loads( len(json.loads(
self.api.getAllInboxMessages())["inboxMessages"]), self.api.getAllInboxMessages())["inboxMessages"]),
@ -122,7 +121,9 @@ class TestAPI(TestAPIProto):
4 4
) )
# Trash function related tests def test_message_trash(self):
"""Test message inbox methods"""
messages_before_delete = len(json.loads(self.api.getAllInboxMessageIds())["inboxMessageIds"]) messages_before_delete = len(json.loads(self.api.getAllInboxMessageIds())["inboxMessageIds"])
self.assertEqual( self.assertEqual(
self.api.trashMessage(hexlify(sample_inbox_msg_ids[0])), self.api.trashMessage(hexlify(sample_inbox_msg_ids[0])),
@ -136,6 +137,18 @@ class TestAPI(TestAPIProto):
len(json.loads(self.api.getAllInboxMessageIds())["inboxMessageIds"]), len(json.loads(self.api.getAllInboxMessageIds())["inboxMessageIds"]),
messages_before_delete - 2 messages_before_delete - 2
) )
self.assertEqual(
self.api.undeleteMessage(hexlify(sample_inbox_msg_ids[0])),
'Undeleted message'
)
self.assertEqual(
self.api.undeleteMessage(hexlify(sample_inbox_msg_ids[1])),
'Undeleted message'
)
self.assertEqual(
len(json.loads(self.api.getAllInboxMessageIds())["inboxMessageIds"]),
messages_before_delete
)
def test_clientstatus_consistency(self): def test_clientstatus_consistency(self):
"""If networkStatus is notConnected networkConnections should be 0""" """If networkStatus is notConnected networkConnections should be 0"""