diff --git a/tests/async_amqp/messaging_tests.py b/tests/async_amqp/messaging_tests.py index 6057bc8d..ba21c4d5 100644 --- a/tests/async_amqp/messaging_tests.py +++ b/tests/async_amqp/messaging_tests.py @@ -6,6 +6,8 @@ # # This file is licensed under the GNU General Public License v3 # (GPLv3). See LICENSE.txt for details. +from pprint import pprint + from zengine.lib.concurrent_amqp_test_client import ConcurrentTestCase, TestQueueManager @@ -18,15 +20,17 @@ def test_channel_list(self): def test_search_user(self): self.post('ulakbus', - dict(view="_zops_search_user", query="x")) + dict(view="_zops_search_user", + query="u")) def show_channel(self, res, req): ch_key = res['channels'][0]['key'] self.post('ulakbus', - dict(view="_zops_show_channel", channel_key=ch_key), - self.create_message) + dict(view="_zops_show_channel", + key=ch_key), + callback=self.create_message) - def create_message(self, res, req): + def create_message(self, res, req=None): self.post('ulakbus', {"view": "_zops_create_message", "message": dict( @@ -36,13 +40,13 @@ def create_message(self, res, req): type=2 )}) - def cmd_user_status(self, res, req): + def cmd_user_status(self, res, req=None): print("CMD: user_status:") - print(res) + pprint(res) def cmd_message(self, res, req=None): print("MESSAGE RECEIVED") - print(res) + pprint(res) def main(): diff --git a/zengine/lib/concurrent_amqp_test_client.py b/zengine/lib/concurrent_amqp_test_client.py index e0248aa5..234c5f1c 100644 --- a/zengine/lib/concurrent_amqp_test_client.py +++ b/zengine/lib/concurrent_amqp_test_client.py @@ -98,10 +98,10 @@ def backend_to_client(self, body): self.message_stack[body['callbackID']] = body self.message_callbacks[body['callbackID']](body) elif 'cmd' in body: - self.cmds[body['cmd']](body) + self.message_callbacks[body['cmd']](body) except: import traceback - print("\n") + print("\nException BODY: %s \n" % pformat(body)) traceback.print_exc() log.info("WRITE MESSAGE TO CLIENT:\n%s" % (pformat(body),)) @@ -137,11 +137,11 @@ class ConcurrentTestCase(object): def __init__(self, queue_manager): log.info("ConcurrentTestCase class init with %s" % queue_manager) self.cmds = {} + self.register_cmds() self.queue_manager = queue_manager self.clients = {} self.make_client('ulakbus') self.run_tests() - self.register_cmds() def make_client(self, username): """