Ejemplo n.º 1
0
Archivo: __init__.py Proyecto: dax/jcl
 def test_replace_handlers(self):
     handlers = [[HandlerType1(), HandlerType2(), HandlerType1()],
                 [HandlerType2(), HandlerType1(), HandlerType2()]]
     jabber.replace_handlers(handlers, HandlerType2, HandlerType3())
     self.assertEquals(handlers[0][0].__class__.__name__, "HandlerType1")
     self.assertEquals(handlers[0][1].__class__.__name__, "HandlerType3")
     self.assertEquals(handlers[0][2].__class__.__name__, "HandlerType1")
     self.assertEquals(handlers[1][0].__class__.__name__, "HandlerType3")
     self.assertEquals(handlers[1][1].__class__.__name__, "HandlerType1")
     self.assertEquals(handlers[1][2].__class__.__name__, "HandlerType3")
Ejemplo n.º 2
0
Archivo: component.py Proyecto: dax/jmc
 def __init__(
     self,
     jid,
     secret,
     server,
     port,
     config,
     config_file,
     lang=Lang(),
     account_manager_class=MailAccountManager,
     command_manager_class=MailCommandManager,
 ):
     """Use FeederComponent behavior and setup feeder and sender
     attributes.
     """
     FeederComponent.__init__(
         self,
         jid,
         secret,
         server,
         port,
         config,
         config_file,
         lang=lang,
         account_manager_class=account_manager_class,
         command_manager_class=command_manager_class,
     )
     self.tick_handlers = [MailFeederHandler(MailFeeder(self), MailSender(self))]
     self.account_manager.account_classes = (IMAPAccount, POP3Account, SMTPAccount)
     self.msg_handlers[0] += [SendMailMessageHandler(self), RootSendMailMessageHandler(self)]
     self.presence_subscribe_handlers += [[MailSubscribeHandler(self)]]
     self.presence_unsubscribe_handlers += [[MailUnsubscribeHandler(self)]]
     self.presence_available_handlers += [[MailPresenceHandler(self)]]
     self.presence_unavailable_handlers += [[MailPresenceHandler(self)]]
     self.disco_get_items_handlers[0] += [IMAPAccountDiscoGetItemsHandler(self)]
     jabber.replace_handlers(
         self.disco_get_info_handlers, CommandRootDiscoGetInfoHandler, MailRootDiscoGetInfoHandler(self)
     )
     jabber.replace_handlers(
         self.disco_get_info_handlers, AccountTypeDiscoGetInfoHandler, MailAccountTypeDiscoGetInfoHandler(self)
     )
     jabber.replace_handlers(
         self.disco_get_info_handlers, AccountDiscoGetInfoHandler, IMAPAccountDiscoGetInfoHandler(self)
     )