Add bare JID as third argument to register post functions
darcs-hash:20070606184704-86b55-6795169def44ccfdfab56f781030d94eb5ef57ac.gz
This commit is contained in:
@@ -170,7 +170,7 @@ class MailAccount(PresenceAccount):
|
|||||||
def _get_register_fields(cls, real_class=None):
|
def _get_register_fields(cls, real_class=None):
|
||||||
"""See Account._get_register_fields
|
"""See Account._get_register_fields
|
||||||
"""
|
"""
|
||||||
def password_post_func(password, default_func):
|
def password_post_func(password, default_func, bare_from_jid):
|
||||||
if password is None or password == "":
|
if password is None or password == "":
|
||||||
return None
|
return None
|
||||||
return password
|
return password
|
||||||
@@ -179,13 +179,13 @@ class MailAccount(PresenceAccount):
|
|||||||
real_class = cls
|
real_class = cls
|
||||||
return PresenceAccount.get_register_fields(real_class) + \
|
return PresenceAccount.get_register_fields(real_class) + \
|
||||||
[("login", "text-single", None,
|
[("login", "text-single", None,
|
||||||
lambda field_value, default_func: \
|
lambda field_value, default_func, bare_from_jid: \
|
||||||
account.mandatory_field(field_value),
|
account.mandatory_field(field_value),
|
||||||
lambda : ""),
|
lambda : ""),
|
||||||
("password", "text-private", None, password_post_func,
|
("password", "text-private", None, password_post_func,
|
||||||
lambda : ""),
|
lambda : ""),
|
||||||
("host", "text-single", None,
|
("host", "text-single", None,
|
||||||
lambda field_value, default_func: \
|
lambda field_value, default_func, bare_from_jid: \
|
||||||
account.mandatory_field(field_value),
|
account.mandatory_field(field_value),
|
||||||
lambda : ""),
|
lambda : ""),
|
||||||
("port", "text-single", None,
|
("port", "text-single", None,
|
||||||
@@ -364,11 +364,6 @@ class IMAPAccount(MailAccount):
|
|||||||
def _get_register_fields(cls, real_class=None):
|
def _get_register_fields(cls, real_class=None):
|
||||||
"""See Account._get_register_fields
|
"""See Account._get_register_fields
|
||||||
"""
|
"""
|
||||||
def password_post_func(password):
|
|
||||||
if password is None or password == "":
|
|
||||||
return None
|
|
||||||
return password
|
|
||||||
|
|
||||||
if real_class is None:
|
if real_class is None:
|
||||||
real_class = cls
|
real_class = cls
|
||||||
return MailAccount.get_register_fields(real_class) + \
|
return MailAccount.get_register_fields(real_class) + \
|
||||||
@@ -569,7 +564,7 @@ class SMTPAccount(Account):
|
|||||||
def _get_register_fields(cls, real_class=None):
|
def _get_register_fields(cls, real_class=None):
|
||||||
"""See Account._get_register_fields
|
"""See Account._get_register_fields
|
||||||
"""
|
"""
|
||||||
def password_post_func(password, default_func):
|
def password_post_func(password, default_func, bare_from_jid):
|
||||||
if password is None or password == "":
|
if password is None or password == "":
|
||||||
return None
|
return None
|
||||||
return password
|
return password
|
||||||
@@ -583,7 +578,7 @@ class SMTPAccount(Account):
|
|||||||
("password", "text-private", None, password_post_func,
|
("password", "text-private", None, password_post_func,
|
||||||
lambda : ""),
|
lambda : ""),
|
||||||
("host", "text-single", None,
|
("host", "text-single", None,
|
||||||
lambda field_value, default_func: \
|
lambda field_value, default_func, bare_from_jid: \
|
||||||
account.mandatory_field(field_value),
|
account.mandatory_field(field_value),
|
||||||
lambda : ""),
|
lambda : ""),
|
||||||
("port", "text-single", None,
|
("port", "text-single", None,
|
||||||
@@ -593,7 +588,7 @@ class SMTPAccount(Account):
|
|||||||
account.default_post_func,
|
account.default_post_func,
|
||||||
lambda : False),
|
lambda : False),
|
||||||
("default_from", "text-single", None,
|
("default_from", "text-single", None,
|
||||||
lambda field_value, default_func: \
|
lambda field_value, default_func, bare_from_jid: \
|
||||||
account.mandatory_field(field_value),
|
account.mandatory_field(field_value),
|
||||||
lambda : ""),
|
lambda : ""),
|
||||||
("store_password", "boolean", None,
|
("store_password", "boolean", None,
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ from jcl.model import account
|
|||||||
from jcl.model.account import Account, PresenceAccount
|
from jcl.model.account import Account, PresenceAccount
|
||||||
from jmc.model.account import MailAccount, POP3Account, IMAPAccount, SMTPAccount
|
from jmc.model.account import MailAccount, POP3Account, IMAPAccount, SMTPAccount
|
||||||
|
|
||||||
from jcl.model.tests.account import Account_TestCase, PresenceAccount_TestCase
|
from jcl.model.tests.account import Account_TestCase, \
|
||||||
|
PresenceAccount_TestCase, InheritableAccount_TestCase
|
||||||
from jmc.model.tests import email_generator, server
|
from jmc.model.tests import email_generator, server
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
@@ -145,11 +146,7 @@ class MailAccount_TestCase(PresenceAccount_TestCase):
|
|||||||
u"Encoded multipart3 with no charset (éàê)\n", \
|
u"Encoded multipart3 with no charset (éàê)\n", \
|
||||||
u"encoded from (éàê)"))
|
u"encoded from (éàê)"))
|
||||||
|
|
||||||
def test_get_register_fields(self):
|
class POP3Account_TestCase(InheritableAccount_TestCase):
|
||||||
register_fields = MailAccount.get_register_fields()
|
|
||||||
self.assertEquals(len(register_fields), 15)
|
|
||||||
|
|
||||||
class POP3Account_TestCase(unittest.TestCase):
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if os.path.exists(DB_PATH):
|
if os.path.exists(DB_PATH):
|
||||||
os.unlink(DB_PATH)
|
os.unlink(DB_PATH)
|
||||||
@@ -167,6 +164,7 @@ class POP3Account_TestCase(unittest.TestCase):
|
|||||||
self.pop3_account.port = 1110
|
self.pop3_account.port = 1110
|
||||||
self.pop3_account.ssl = False
|
self.pop3_account.ssl = False
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
self.account_class = POP3Account
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
@@ -275,11 +273,7 @@ class POP3Account_TestCase(unittest.TestCase):
|
|||||||
u"mymessage\n", \
|
u"mymessage\n", \
|
||||||
u"user@test.com")))
|
u"user@test.com")))
|
||||||
|
|
||||||
def test_get_register_fields(self):
|
class IMAPAccount_TestCase(InheritableAccount_TestCase):
|
||||||
register_fields = POP3Account.get_register_fields()
|
|
||||||
self.assertEquals(len(register_fields), 15)
|
|
||||||
|
|
||||||
class IMAPAccount_TestCase(unittest.TestCase):
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if os.path.exists(DB_PATH):
|
if os.path.exists(DB_PATH):
|
||||||
os.unlink(DB_PATH)
|
os.unlink(DB_PATH)
|
||||||
@@ -297,6 +291,7 @@ class IMAPAccount_TestCase(unittest.TestCase):
|
|||||||
self.imap_account.port = 1143
|
self.imap_account.port = 1143
|
||||||
self.imap_account.ssl = False
|
self.imap_account.ssl = False
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
self.account_class = IMAPAccount
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
@@ -384,14 +379,10 @@ class IMAPAccount_TestCase(unittest.TestCase):
|
|||||||
(u"From : None\nSubject : None\n\nbody text\r\n\n", \
|
(u"From : None\nSubject : None\n\nbody text\r\n\n", \
|
||||||
u"None")))
|
u"None")))
|
||||||
|
|
||||||
def test_get_register_fields(self):
|
|
||||||
register_fields = IMAPAccount.get_register_fields()
|
|
||||||
self.assertEquals(len(register_fields), 16)
|
|
||||||
|
|
||||||
class SMTPAccount_TestCase(Account_TestCase):
|
class SMTPAccount_TestCase(Account_TestCase):
|
||||||
def test_get_register_fields(self):
|
def setUp(self):
|
||||||
register_fields = SMTPAccount.get_register_fields()
|
Account_TestCase.setUp(self)
|
||||||
self.assertEquals(len(register_fields), 8)
|
self.account_class = SMTPAccount
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
|
|||||||
Reference in New Issue
Block a user