From 0023fc4b3d0988b166e8c217cdf4826c399406a7 Mon Sep 17 00:00:00 2001 From: navjot Date: Wed, 4 Nov 2020 20:39:29 +0530 Subject: [PATCH] Written test case for helper_sent.insert method --- src/helper_sent.py | 2 -- src/tests/core.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/helper_sent.py b/src/helper_sent.py index 1cf48ece..ff82df1d 100644 --- a/src/helper_sent.py +++ b/src/helper_sent.py @@ -12,10 +12,8 @@ def insert(t): if not t[0] or not t[-1]: temp = list(t) if not t[0]: - print('zero index is not available') temp[0] = uuid.uuid4().bytes # if msgid is empty the put uuid if not t[-1]: - print('Lasr index is not available') temp[-1] = BMConfigParser().getint('bitmessagesettings', 'ttl') t = tuple(temp) sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t) diff --git a/src/tests/core.py b/src/tests/core.py index ac1f9e7a..a7209c08 100644 --- a/src/tests/core.py +++ b/src/tests/core.py @@ -238,6 +238,43 @@ class TestCore(unittest.TestCase): streams = decoded[7:] self.assertEqual(streams, [1, 2, 3]) + def test_insert_method(self): + """Test insert method of helper_sent module with message sending""" + import helper_sent + from addresses import decodeAddress + from bmconfigparser import BMConfigParser + from helper_ackPayload import genAckPayload + + toAddress = 'BM-2cVWtdUzPwF7UNGDrZftWuHWiJ6xxBpiSP' # this address is autoresponder address + message = 'test message' + subject = 'test subject' + fromAddress = 'BM-2cVdyaMNhYfnw8j1SDPW3QBhjzKzP9vtdp' # here use your own address for testing + + status, addressVersionNumber, streamNumber, ripe = decodeAddress( + toAddress) + encoding = 2 + stealthLevel = BMConfigParser().safeGetInt( + 'bitmessagesettings', 'ackstealthlevel') + ackdata = genAckPayload(streamNumber, stealthLevel) + print('ackdata: ', ackdata) + t = ('', + toAddress, + ripe, + fromAddress, + subject, + message, + ackdata, + int(time.time()), # sentTime + int(time.time()), # lastActionTime + 0, + 'msgqueued', + 0, + 'sent', + encoding, + 0) + helper_sent.insert(t) + self.assertTrue(True) + def run(): """Starts all tests defined in this module"""