diff options
-rw-r--r-- | src/jmc/jabber/component.py | 11 | ||||
-rw-r--r-- | src/jmc/jabber/disco.py | 2 | ||||
-rw-r--r-- | src/jmc/jabber/tests/__init__.py | 3 | ||||
-rw-r--r-- | src/jmc/jabber/tests/component.py | 4 | ||||
-rw-r--r-- | src/jmc/jabber/tests/disco.py | 25 |
5 files changed, 34 insertions, 11 deletions
diff --git a/src/jmc/jabber/component.py b/src/jmc/jabber/component.py index 075f718..b0be13f 100644 --- a/src/jmc/jabber/component.py +++ b/src/jmc/jabber/component.py @@ -48,6 +48,7 @@ from jmc.jabber.presence import MailSubscribeHandler, \ from jmc.model.account import MailAccount, IMAPAccount, POP3Account, \ SMTPAccount from jmc.lang import Lang +from jmc.jabber.command import MailCommandManager class MailAccountManager(AccountManager): def account_get_register(self, info_query, @@ -109,7 +110,8 @@ class MailComponent(FeederComponent): config, config_file, lang=Lang(), - account_manager_class=MailAccountManager): + account_manager_class=MailAccountManager, + command_manager_class=MailCommandManager): """Use FeederComponent behavior and setup feeder and sender attributes. """ @@ -121,7 +123,8 @@ class MailComponent(FeederComponent): config, config_file, lang=lang, - account_manager_class=account_manager_class) + account_manager_class=account_manager_class, + command_manager_class=command_manager_class) self.handler = MailFeederHandler(MailFeeder(self), MailSender(self)) self.account_manager.account_classes = (IMAPAccount, POP3Account, @@ -142,10 +145,6 @@ class MailComponent(FeederComponent): jabber.replace_handlers(self.disco_get_info_handlers, AccountDiscoGetInfoHandler, IMAPAccountDiscoGetInfoHandler(self)) -# for hg in self.disco_get_items_handlers: -# print "----" -# for h in hg: -# print str(h) class MailFeeder(Feeder): """Email check""" diff --git a/src/jmc/jabber/disco.py b/src/jmc/jabber/disco.py index e398fbb..b97c301 100644 --- a/src/jmc/jabber/disco.py +++ b/src/jmc/jabber/disco.py @@ -30,6 +30,7 @@ from jcl.model import account from jcl.jabber.command import CommandRootDiscoGetInfoHandler from jcl.jabber.disco import AccountTypeDiscoGetInfoHandler, \ AccountDiscoGetInfoHandler, DiscoHandler +import jcl.jabber.command as command from jmc.model.account import IMAPAccount @@ -60,6 +61,7 @@ class IMAPAccountDiscoGetInfoHandler(AccountDiscoGetInfoHandler): lang_class, node, disco_obj, data) + disco_infos[0].add_feature(command.COMMAND_NS) splitted_node = node.split("/") splitted_node_len = len(splitted_node) if splitted_node_len > 1 and \ diff --git a/src/jmc/jabber/tests/__init__.py b/src/jmc/jabber/tests/__init__.py index e060efe..72a03d7 100644 --- a/src/jmc/jabber/tests/__init__.py +++ b/src/jmc/jabber/tests/__init__.py @@ -3,12 +3,13 @@ __revision__ = "" import unittest -from jmc.jabber.tests import component, disco +from jmc.jabber.tests import component, disco, command def suite(): suite = unittest.TestSuite() suite.addTest(component.suite()) suite.addTest(disco.suite()) + suite.addTest(command.suite()) return suite if __name__ == '__main__': diff --git a/src/jmc/jabber/tests/component.py b/src/jmc/jabber/tests/component.py index 8312a8b..f54bf53 100644 --- a/src/jmc/jabber/tests/component.py +++ b/src/jmc/jabber/tests/component.py @@ -153,6 +153,10 @@ class MockIMAPAccount(MockMailAccount, IMAPAccount): return ["subdir1", "subdir2"] return [] + def get_mail_with_attachment_list(self): + return [("1", "mail 1"), + ("2", "mail 2")] + class MockPOP3Account(MockMailAccount, POP3Account): def _init(self, *args, **kw): POP3Account._init(self, *args, **kw) diff --git a/src/jmc/jabber/tests/disco.py b/src/jmc/jabber/tests/disco.py index 9ca6dc2..fc8ba54 100644 --- a/src/jmc/jabber/tests/disco.py +++ b/src/jmc/jabber/tests/disco.py @@ -3,18 +3,18 @@ ## Login : David Rousselie <dax@happycoders.org> ## Started on Sun Jul 8 20:59:32 2007 David Rousselie ## $Id$ -## +## ## Copyright (C) 2007 David Rousselie ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. -## +## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. -## +## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -22,7 +22,9 @@ import unittest -from jmc.jabber.disco import MailRootDiscoGetInfoHandler +from jmc.jabber.disco import MailRootDiscoGetInfoHandler, \ + IMAPAccountDiscoGetInfoHandler +from jmc.lang import Lang class MockDiscoIndentity(object): def __init__(self): @@ -57,9 +59,24 @@ class MailRootDiscoGetInfoHandler_TestCase(unittest.TestCase): self.assertTrue(disco_infos[0].identity_is("gateway", "smtp")) self.assertTrue(disco_infos[0].identity_is("headline", "newmail")) +class IMAPAccountDiscoGetInfoHandler_TestCase(unittest.TestCase): + def test_handle_not_imap(self): + component = MockComponent() + component.name = "Mock component" + component.disco_identity.category = "gateway" + component.disco_identity.type = "smtp" + component.account_manager.has_multiple_account_type = True + handler = IMAPAccountDiscoGetInfoHandler(component) + # stanza, lang_class, node, disco_obj, data + disco_infos = handler.handle(None, Lang.en, "account@jmc.test.com/POP3", + None, None) + self.assertTrue(disco_infos[0].has_feature("jabber:iq:register")) + self.assertTrue(disco_infos[0].has_feature("http://jabber.org/protocol/commands")) + def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(MailRootDiscoGetInfoHandler_TestCase, 'test')) + suite.addTest(unittest.makeSuite(IMAPAccountDiscoGetInfoHandler_TestCase, 'test')) return suite if __name__ == '__main__': |