From cde3a9f16f6ef924a28e326e806ebafa0cb74e84 Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Sun, 13 May 2007 19:12:50 +0200 Subject: [PATCH] Reuse PresenceAccount unit tests darcs-hash:20070513171250-86b55-daf3937f6c3dc004d246cbb81da91b91756993d2.gz --- run_tests.py | 4 ++-- src/jmc.py | 2 +- src/jmc/model/account.py | 8 ++------ tests/jmc/model/test_account.py | 4 +++- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/run_tests.py b/run_tests.py index f321d48..3093966 100644 --- a/run_tests.py +++ b/run_tests.py @@ -74,5 +74,5 @@ if __name__ == '__main__': coverage.analysis(jmc.model.account) coverage.report([jmc.jabber.component, \ - jmc.lang, \ - jmc.model.account]) + jmc.lang, \ + jmc.model.account]) diff --git a/src/jmc.py b/src/jmc.py index 229f0d1..692806b 100755 --- a/src/jmc.py +++ b/src/jmc.py @@ -54,7 +54,7 @@ del account.hub.threadConnection component = MailComponent("jmc.localhost", \ "secret", \ "127.0.0.1", \ - 5349, \ + 5347, \ "sqlite://" + DB_URL) component.run() logger.debug("JMC is exiting") diff --git a/src/jmc/model/account.py b/src/jmc/model/account.py index 00ceedb..e1e8b12 100644 --- a/src/jmc/model/account.py +++ b/src/jmc/model/account.py @@ -172,16 +172,12 @@ class MailAccount(PresenceAccount): real_class = cls return PresenceAccount.get_register_fields(real_class) + \ [("login", "text-single", None, \ - lambda field_value, default_func: account.mandatory_field("login", \ - field_value, \ - default_func), \ + lambda field_value, default_func: account.mandatory_field(field_value), \ lambda : ""), \ ("password", "text-private", None, password_post_func, \ lambda : ""), \ ("host", "text-single", None, \ - lambda field_value, default_func: account.mandatory_field("host", \ - field_value, \ - default_func), \ + lambda field_value, default_func: account.mandatory_field(field_value), \ lambda : ""), \ ("port", "text-single", None, \ account.int_post_func, \ diff --git a/tests/jmc/model/test_account.py b/tests/jmc/model/test_account.py index 1f6d8fe..f1bba49 100644 --- a/tests/jmc/model/test_account.py +++ b/tests/jmc/model/test_account.py @@ -33,6 +33,7 @@ from jcl.model import account from jcl.model.account import Account, PresenceAccount from jmc.model.account import MailAccount, POP3Account, IMAPAccount +from jcl.model.tests.account import PresenceAccount_TestCase from tests.jmc import email_generator, dummy_server if sys.platform == "win32": @@ -41,7 +42,7 @@ else: DB_PATH = "/tmp/test.db" DB_URL = DB_PATH # + "?debug=1&debugThreading=1" -class MailAccount_TestCase(unittest.TestCase): +class MailAccount_TestCase(PresenceAccount_TestCase): def setUp(self): if os.path.exists(DB_PATH): os.unlink(DB_PATH) @@ -53,6 +54,7 @@ class MailAccount_TestCase(unittest.TestCase): name = "account1", \ jid = "account1@jmc.test.com") del account.hub.threadConnection + self.account_class = MailAccount def tearDown(self): account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)