add session tests

This commit is contained in:
2019-12-07 16:21:20 +01:00
parent 3c5285a7d2
commit 3b31f092bd
25 changed files with 705 additions and 193 deletions

View File

@ -149,7 +149,7 @@ class PublishDispatcher:
return
# config is ok, so publish the message
for function_obj in self.messages[version][message]['functions']:
for function_obj in self.messages[version][message].get('functions', []):
function = function_obj['function']
module_name = function.__module__.split('.')[-2]
function_name = function.__name__
@ -163,21 +163,21 @@ class PublishDispatcher:
if function_obj['risotto_context']:
kw['risotto_context'] = risotto_context
# send event
await function(self.injected_self[function_obj['module']], **kw)
returns = await function(self.injected_self[function_obj['module']], **kw)
except Exception as err:
if DEBUG:
print_exc()
log.error_msg(risotto_context, kwargs, err, info_msg)
continue
else:
log.info_msg(risotto_context, kwargs, info_msg)
# notification
if obj.get('notification'):
notif_version, notif_message = obj['notification'].split('.', 1)
await self.publish(notif_version,
notif_message,
risotto_context,
**returns)
# notification
if function_obj.get('notification'):
notif_version, notif_message = function_obj['notification'].split('.', 1)
await self.publish(notif_version,
notif_message,
risotto_context,
**returns)
class Dispatcher(register.RegisterDispatcher, CallDispatcher, PublishDispatcher):