From 21cb4e516da2db08aa4dfc08d9ac86ccd443cbea Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Thu, 18 Nov 2021 21:24:05 +0530 Subject: [PATCH] Added testmode check for HandleclearUISignalQueue & HandleGetStatusBar functions, replaced sample_inbox_msg_receiver_address by sample_deterministic_addr4 --- src/api.py | 4 ++++ src/testmode_init.py | 20 ++++++++++---------- src/tests/samples.py | 1 - src/tests/test_api.py | 5 ++--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/api.py b/src/api.py index 0dfa3e7d..c5e39055 100644 --- a/src/api.py +++ b/src/api.py @@ -310,6 +310,9 @@ class command(object): # pylint: disable=too-few-public-methods self.aliases = aliases def __call__(self, func): + if func.__name__ in ["HandleclearUISignalQueue", "HandleGetStatusBar"] \ + and not state.testmode: + return None if BMConfigParser().safeGet( 'bitmessagesettings', 'apivariant') == 'legacy': def wrapper(*args): @@ -1428,6 +1431,7 @@ class BMRPCDispatcher(object): def HandleclearUISignalQueue(self): """clear UISignalQueue""" queues.UISignalQueue.queue.clear() + return "success" @command('statusBar') def HandleStatusBar(self, message): diff --git a/src/testmode_init.py b/src/testmode_init.py index 4be3626c..a088afc1 100644 --- a/src/testmode_init.py +++ b/src/testmode_init.py @@ -4,8 +4,8 @@ import uuid import helper_inbox import helper_sql -# from .tests.samples import sample_inbox_msg_ids, sample_inbox_msg_receiver_address -sample_inbox_msg_receiver_address = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK' +# from .tests.samples import sample_inbox_msg_ids, sample_deterministic_addr4 +sample_deterministic_addr4 = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK' sample_inbox_msg_ids = ['27e644765a3e4b2e973ee7ccf958ea20', '51fc5531-3989-4d69-bbb5-68d64b756f5b', '2c975c515f8b414db5eea60ba57ba455', 'bc1f2d8a-681c-4cc0-9a12-6067c7e1ac24'] @@ -15,23 +15,23 @@ def populate_api_test_data(): helper_sql.sql_ready.wait() test1 = ( - sample_inbox_msg_ids[0], sample_inbox_msg_receiver_address, - sample_inbox_msg_receiver_address, 'Test1 subject', int(time.time()), + sample_inbox_msg_ids[0], sample_deterministic_addr4, + sample_deterministic_addr4, 'Test1 subject', int(time.time()), 'Test1 body', 'inbox', 2, 0, uuid.uuid4().bytes ) test2 = ( - sample_inbox_msg_ids[1], sample_inbox_msg_receiver_address, - sample_inbox_msg_receiver_address, 'Test2 subject', int(time.time()), + sample_inbox_msg_ids[1], sample_deterministic_addr4, + sample_deterministic_addr4, 'Test2 subject', int(time.time()), 'Test2 body', 'inbox', 2, 0, uuid.uuid4().bytes ) test3 = ( - sample_inbox_msg_ids[2], sample_inbox_msg_receiver_address, - sample_inbox_msg_receiver_address, 'Test3 subject', int(time.time()), + sample_inbox_msg_ids[2], sample_deterministic_addr4, + sample_deterministic_addr4, 'Test3 subject', int(time.time()), 'Test3 body', 'inbox', 2, 0, uuid.uuid4().bytes ) test4 = ( - sample_inbox_msg_ids[3], sample_inbox_msg_receiver_address, - sample_inbox_msg_receiver_address, 'Test4 subject', int(time.time()), + sample_inbox_msg_ids[3], sample_deterministic_addr4, + sample_deterministic_addr4, 'Test4 subject', int(time.time()), 'Test4 body', 'inbox', 2, 0, uuid.uuid4().bytes ) helper_inbox.insert(test1) diff --git a/src/tests/samples.py b/src/tests/samples.py index 94bef71c..8c36dd89 100644 --- a/src/tests/samples.py +++ b/src/tests/samples.py @@ -37,7 +37,6 @@ sample_daddr3_512 = 18875720106589866286514488037355423395410802084648916523381 sample_daddr4_512 = 25152821841976547050350277460563089811513157529113201589004 sample_statusbar_msg = "new status bar message" -sample_inbox_msg_receiver_address = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK' sample_inbox_msg_ids = ['27e644765a3e4b2e973ee7ccf958ea20', '51fc5531-3989-4d69-bbb5-68d64b756f5b', '2c975c515f8b414db5eea60ba57ba455', 'bc1f2d8a-681c-4cc0-9a12-6067c7e1ac24'] sample_test_subscription_address = ['BM-2cWQLCBGorT9pUGkYSuGGVr9LzE4mRnQaq', 'BM-GtovgYdgs7qXPkoYaRgrLFuFKz1SFpsw'] diff --git a/src/tests/test_api.py b/src/tests/test_api.py index 71ef9157..167ff298 100644 --- a/src/tests/test_api.py +++ b/src/tests/test_api.py @@ -13,8 +13,7 @@ import psutil from .samples import ( sample_seed, sample_deterministic_addr3, sample_deterministic_addr4, sample_statusbar_msg, - sample_inbox_msg_receiver_address, sample_inbox_msg_ids, sample_test_subscription_address, - sample_subscription_name) + sample_inbox_msg_ids, sample_test_subscription_address, sample_subscription_name) from .test_process import TestProcessProto @@ -114,7 +113,7 @@ class TestAPI(TestAPIProto): ) self.assertTrue( len(json.loads( - self.api.getInboxMessagesByReceiver(sample_inbox_msg_receiver_address))["inboxMessages"]) == 2 + self.api.getInboxMessagesByReceiver(sample_deterministic_addr4))["inboxMessages"]) == 2 ) def test_delete_message(self):