References to Config static getters moved from the constructor declaration to the constructor body to prevent the default Config object to be initialized before the time and any config override to be ignored. This should also fix the tests, #33
This commit is contained in:
parent
9220b23471
commit
2a192dacc1
2 changed files with 5 additions and 2 deletions
|
@ -69,7 +69,8 @@ class EventAction(Request):
|
||||||
""" Event hook action class. It is a special type of runnable request
|
""" Event hook action class. It is a special type of runnable request
|
||||||
whose fields can be configured later depending on the event context """
|
whose fields can be configured later depending on the event context """
|
||||||
|
|
||||||
def __init__(self, target=Config.get('device_id'), action=None, **args):
|
def __init__(self, target=None, action=None, **args):
|
||||||
|
if target is None: target=Config.get('device_id')
|
||||||
super().__init__(target=target, action=action, **args)
|
super().__init__(target=target, action=action, **args)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,14 @@ class EventProcessor(object):
|
||||||
""" Event processor class. Checks an event against the configured
|
""" Event processor class. Checks an event against the configured
|
||||||
rules and executes any matching event hooks """
|
rules and executes any matching event hooks """
|
||||||
|
|
||||||
def __init__(self, hooks=Config.get_event_hooks(), **kwargs):
|
def __init__(self, hooks=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Params:
|
Params:
|
||||||
hooks -- List of event hooks (default: any entry in the config
|
hooks -- List of event hooks (default: any entry in the config
|
||||||
named as event.hook.<hook_name> """
|
named as event.hook.<hook_name> """
|
||||||
|
|
||||||
|
if hooks is None: hooks = Config.get_event_hooks()
|
||||||
|
|
||||||
self.hooks = []
|
self.hooks = []
|
||||||
for (name, hook) in hooks.items():
|
for (name, hook) in hooks.items():
|
||||||
h = EventHook.build(name=name, hook=hook)
|
h = EventHook.build(name=name, hook=hook)
|
||||||
|
|
Loading…
Reference in a new issue