Add raise exception when callback already asigned and remove not necessary callback params.
@@ -5,7 +5,7 @@ __copyright__ = 'Copyright (C) 2018, Nokia'
__email__ = 'michal.ernst@nokia.com, marcin.usielski@nokia.com'
from moler.connection_observer import ConnectionObserver
-from moler.exceptions import NoDetectPatternProvided
+from moler.exceptions import NoDetectPatternProvided, MolerException
from moler.helpers import instance_id
from moler.exceptions import ResultAlreadySet
import re
@@ -47,12 +47,13 @@ class Event(ConnectionObserver):
raise NoDetectPatternProvided(self)
def add_event_occurred_callback(self, callback):
+ if not self.callback:
self.callback = callback
+ else:
+ raise MolerException("Cannot assign already assigned 'self.callback'.")
def remove_event_occurred_callback(self):
- if not (self.callback_params is None):
self.callback = None
- self.callback_params = dict()
def notify(self):
self.callback()
