Ejemplo n.º 1
0
 def __init__ (self, localRouter):
     # generate a URI and logname
     uri,logname = makeUri(self.__class__)
     self._log = logging.getLogger( logname )
     EventHandler.__init__(self, uri, self.doHandleEvent)
     # no extra config as yet.
     self.__running = False
     # this is a 3 level structure.
     # dictionary (key - type) of dictionaries (key - source) of lists(events)
     self._typeConfig = dict()
     self._localRouter = localRouter
     self._subscribeTime = 30
Ejemplo n.º 2
0
 def testCreateEventHandler1(self):
     eh = EventHandler("EventHandlerUri", handleEvent, initSub, endSub)
     self.assertEqual(eh.getUri(), "EventHandlerUri")
     ev = makeEvent("EventUri", source=eh.getUri())
     sh = eh.handleEvent(ev).syncValue()
     self.assertEqual(sh, Status(URI.Status_TRIGGERED, ev.getType()))
     self.assertEqual(sh.getMessage(), ev.getType())
     ss = eh.initSubscription(StatusVal.OK).syncValue()
     self.assertEqual(ss, Status(URI.Status_SUBSCRIBED, str(StatusVal.OK)))
     self.assertEqual(ss.getMessage(), str(StatusVal.OK))
     su = eh.endSubscription(StatusVal.OK).syncValue()
     self.assertEqual(su, Status(URI.Status_UNSUBSCRIBED,
                                 str(StatusVal.OK)))
     self.assertEqual(su.getMessage(), str(StatusVal.OK))
     return
Ejemplo n.º 3
0
 def testCreateEventHandler1(self):
     eh = EventHandler("EventHandlerUri", handleEvent, initSub, endSub)
     self.assertEqual(eh.getUri(), "EventHandlerUri")
     ev = makeEvent("EventUri", source=eh.getUri())
     sh = eh.handleEvent(ev).syncValue()
     self.assertEqual(sh, Status(URI.Status_TRIGGERED, ev.getType()))
     self.assertEqual(sh.getMessage(), ev.getType())
     ss = eh.initSubscription(StatusVal.OK).syncValue()
     self.assertEqual(ss, Status(URI.Status_SUBSCRIBED, str(StatusVal.OK)))
     self.assertEqual(ss.getMessage(), str(StatusVal.OK))
     su = eh.endSubscription(StatusVal.OK).syncValue()
     self.assertEqual(su, Status(URI.Status_UNSUBSCRIBED, str(StatusVal.OK)))
     self.assertEqual(su.getMessage(), str(StatusVal.OK))
     return
Ejemplo n.º 4
0
 def testEventHandlerEqual2(self):
     eh1 = EventHandler("EventHandlerUri1", handleEvent, initSub, endSub)
     eh2 = EventHandler("EventHandlerUri2", handleEvent, initSub, endSub)
     self.assertNotEqual(eh1, eh2)