Skip to content

Commit

Permalink
amqp based concurrent test framework, nearly finished
Browse files Browse the repository at this point in the history
rref #5367
rref #5366

ref #66
ref #65
  • Loading branch information
evrenesat committed Jul 26, 2016
1 parent 114a8d6 commit e210ec8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 11 additions & 7 deletions tests/async_amqp/messaging_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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(
Expand All @@ -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():
Expand Down
6 changes: 3 additions & 3 deletions zengine/lib/concurrent_amqp_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),))
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit e210ec8

Please sign in to comment.