Add bare JID as third argument to register form post functions
darcs-hash:20070606184618-86b55-d2a169b118adbec03202b7f9508d809d09bebb03.gz
This commit is contained in:
@@ -677,8 +677,11 @@ class AccountManager(object):
|
|||||||
"""Handle get_register for given account_class"""
|
"""Handle get_register for given account_class"""
|
||||||
info_query = info_query.make_result_response()
|
info_query = info_query.make_result_response()
|
||||||
query = info_query.new_query("jabber:iq:register")
|
query = info_query.new_query("jabber:iq:register")
|
||||||
|
from_jid = info_query.get_from()
|
||||||
|
bare_from_jid = unicode(from_jid.bare())
|
||||||
self.get_reg_form(lang_class,
|
self.get_reg_form(lang_class,
|
||||||
account_class).as_xml(query)
|
account_class,
|
||||||
|
bare_from_jid).as_xml(query)
|
||||||
return [info_query]
|
return [info_query]
|
||||||
|
|
||||||
def account_type_get_register(self, info_query, account_type, lang_class):
|
def account_type_get_register(self, info_query, account_type, lang_class):
|
||||||
@@ -726,6 +729,8 @@ class AccountManager(object):
|
|||||||
"""Populate given account"""
|
"""Populate given account"""
|
||||||
field = None
|
field = None
|
||||||
result = []
|
result = []
|
||||||
|
from_jid = info_query.get_from()
|
||||||
|
bare_from_jid = unicode(from_jid.bare())
|
||||||
self.db_connect()
|
self.db_connect()
|
||||||
try:
|
try:
|
||||||
for (field, field_type, field_options, field_post_func,
|
for (field, field_type, field_options, field_post_func,
|
||||||
@@ -736,7 +741,8 @@ class AccountManager(object):
|
|||||||
else:
|
else:
|
||||||
value = None
|
value = None
|
||||||
setattr(_account, field,
|
setattr(_account, field,
|
||||||
field_post_func(value, field_default_func))
|
field_post_func(value, field_default_func,
|
||||||
|
bare_from_jid))
|
||||||
except FieldError, exception:
|
except FieldError, exception:
|
||||||
_account.destroySelf()
|
_account.destroySelf()
|
||||||
type, value, stack = sys.exc_info()
|
type, value, stack = sys.exc_info()
|
||||||
@@ -1037,7 +1043,7 @@ class AccountManager(object):
|
|||||||
"""Delete connection associated to the current thread"""
|
"""Delete connection associated to the current thread"""
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
def get_reg_form(self, lang_class, _account_class):
|
def get_reg_form(self, lang_class, _account_class, bare_from_jid):
|
||||||
"""Return register form based on language and account class
|
"""Return register form based on language and account class
|
||||||
"""
|
"""
|
||||||
reg_form = Form(title=lang_class.register_title,
|
reg_form = Form(title=lang_class.register_title,
|
||||||
@@ -1078,20 +1084,20 @@ class AccountManager(object):
|
|||||||
field.add_option(label=label,
|
field.add_option(label=label,
|
||||||
values=[option_value])
|
values=[option_value])
|
||||||
try:
|
try:
|
||||||
post_func(None, default_func)
|
post_func(None, default_func, bare_from_jid)
|
||||||
except:
|
except:
|
||||||
self.__logger.debug("Setting field " + field_name + " required")
|
self.__logger.debug("Setting field " + field_name + " required")
|
||||||
field.required = True
|
field.required = True
|
||||||
## TODO : get default value if any
|
|
||||||
return reg_form
|
return reg_form
|
||||||
|
|
||||||
def get_reg_form_init(self, lang_class, _account):
|
def get_reg_form_init(self, lang_class, _account):
|
||||||
"""Return register form for an existing account (update)
|
"""Return register form for an existing account (update)
|
||||||
"""
|
"""
|
||||||
reg_form = self.get_reg_form(lang_class, _account.__class__)
|
reg_form = self.get_reg_form(lang_class, _account.__class__,
|
||||||
|
_account.user_jid)
|
||||||
reg_form["name"].value = _account.name
|
reg_form["name"].value = _account.name
|
||||||
reg_form["name"].type = "hidden"
|
reg_form["name"].type = "hidden"
|
||||||
for field in reg_form.fields: # TODO
|
for field in reg_form.fields:
|
||||||
if hasattr(_account, field.name):
|
if hasattr(_account, field.name):
|
||||||
field.value = getattr(_account, field.name)
|
field.value = getattr(_account, field.name)
|
||||||
return reg_form
|
return reg_form
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##
|
##
|
||||||
## account.py
|
## account.py
|
||||||
## Login : David Rousselie <dax@happycoders.org>
|
## Login : David Rousselie <dax@happycoders.org>
|
||||||
@@ -37,13 +37,13 @@ OFFLINE = "offline"
|
|||||||
ONLINE = "online"
|
ONLINE = "online"
|
||||||
|
|
||||||
|
|
||||||
def default_post_func(field_value, default_func):
|
def default_post_func(field_value, default_func, bare_from_jid):
|
||||||
"""Default post process function: do nothing"""
|
"""Default post process function: do nothing"""
|
||||||
if field_value is None or str(field_value) == "":
|
if field_value is None or str(field_value) == "":
|
||||||
return default_func()
|
return default_func()
|
||||||
return field_value
|
return field_value
|
||||||
|
|
||||||
def int_post_func(field_value, default_func):
|
def int_post_func(field_value, default_func, bare_from_jid):
|
||||||
"""Return an integer from integer field value"""
|
"""Return an integer from integer field value"""
|
||||||
if field_value is None or str(field_value) == "":
|
if field_value is None or str(field_value) == "":
|
||||||
return int(default_func())
|
return int(default_func())
|
||||||
@@ -67,8 +67,8 @@ class Account(InheritableSQLObject):
|
|||||||
name = StringCol()
|
name = StringCol()
|
||||||
jid = StringCol()
|
jid = StringCol()
|
||||||
## Not yet used first_check = BoolCol(default = True)
|
## Not yet used first_check = BoolCol(default = True)
|
||||||
__status = StringCol(default = OFFLINE, dbName = "status")
|
__status = StringCol(default=OFFLINE, dbName="status")
|
||||||
in_error = BoolCol(default = False)
|
in_error = BoolCol(default=False)
|
||||||
|
|
||||||
## Use these attributs to support volatile password
|
## Use these attributs to support volatile password
|
||||||
## login = StringCol(default = "")
|
## login = StringCol(default = "")
|
||||||
@@ -197,42 +197,48 @@ class PresenceAccount(Account):
|
|||||||
if real_class is None:
|
if real_class is None:
|
||||||
real_class = cls
|
real_class = cls
|
||||||
return Account.get_register_fields(real_class) + \
|
return Account.get_register_fields(real_class) + \
|
||||||
[(None, None, None, None, None), \
|
[(None, None, None, None, None),
|
||||||
("chat_action", "list-single", \
|
("chat_action", "list-single",
|
||||||
[str(action) for action in get_possibles_actions("chat_action")], \
|
[str(action) for action in get_possibles_actions("chat_action")],
|
||||||
lambda action, default_func: is_action_possible("chat_action", \
|
lambda action, default_func, bare_from_jid: \
|
||||||
action, \
|
is_action_possible("chat_action",
|
||||||
default_func), \
|
action,
|
||||||
lambda : get_default_presence_action("chat_action")), \
|
default_func),
|
||||||
("online_action", "list-single", \
|
lambda : get_default_presence_action("chat_action")),
|
||||||
[str(action) for action in get_possibles_actions("online_action")], \
|
("online_action", "list-single",
|
||||||
lambda action, default_func: is_action_possible("online_action", \
|
[str(action) for action in get_possibles_actions("online_action")],
|
||||||
action, \
|
lambda action, default_func, bare_from_jid: \
|
||||||
default_func), \
|
is_action_possible("online_action",
|
||||||
lambda : get_default_presence_action("online_action")), \
|
action,
|
||||||
("away_action", "list-single", \
|
default_func),
|
||||||
[str(action) for action in get_possibles_actions("away_action")], \
|
lambda : get_default_presence_action("online_action")),
|
||||||
lambda action, default_func: is_action_possible("away_action", \
|
("away_action", "list-single",
|
||||||
action, \
|
[str(action) for action in get_possibles_actions("away_action")],
|
||||||
default_func), \
|
lambda action, default_func, bare_from_jid: \
|
||||||
lambda : get_default_presence_action("away_action")), \
|
is_action_possible("away_action",
|
||||||
("xa_action", "list-single", \
|
action,
|
||||||
[str(action) for action in get_possibles_actions("xa_action")], \
|
default_func),
|
||||||
lambda action, default_func: is_action_possible("xa_action", \
|
lambda : get_default_presence_action("away_action")),
|
||||||
action, \
|
("xa_action", "list-single",
|
||||||
default_func), \
|
[str(action) for action in get_possibles_actions("xa_action")],
|
||||||
lambda : get_default_presence_action("xa_action")), \
|
lambda action, default_func, bare_from_jid: \
|
||||||
("dnd_action", "list-single", \
|
is_action_possible("xa_action",
|
||||||
[str(action) for action in get_possibles_actions("dnd_action")], \
|
action,
|
||||||
lambda action, default_func: is_action_possible("dnd_action", \
|
default_func),
|
||||||
action, \
|
lambda : get_default_presence_action("xa_action")),
|
||||||
default_func), \
|
("dnd_action", "list-single",
|
||||||
lambda : get_default_presence_action("dnd_action")), \
|
[str(action) for action in get_possibles_actions("dnd_action")],
|
||||||
("offline_action", "list-single", \
|
lambda action, default_func, bare_from_jid: \
|
||||||
[str(action) for action in get_possibles_actions("offline_action")], \
|
is_action_possible("dnd_action",
|
||||||
lambda action, default_func: is_action_possible("offline_action", \
|
action,
|
||||||
action, \
|
default_func),
|
||||||
default_func), \
|
lambda : get_default_presence_action("dnd_action")),
|
||||||
|
("offline_action", "list-single",
|
||||||
|
[str(action) for action in get_possibles_actions("offline_action")],
|
||||||
|
lambda action, default_func, bare_from_jid: \
|
||||||
|
is_action_possible("offline_action",
|
||||||
|
action,
|
||||||
|
default_func),
|
||||||
lambda : get_default_presence_action("offline_action"))]
|
lambda : get_default_presence_action("offline_action"))]
|
||||||
|
|
||||||
get_register_fields = classmethod(_get_register_fields)
|
get_register_fields = classmethod(_get_register_fields)
|
||||||
|
|||||||
@@ -38,15 +38,15 @@ else:
|
|||||||
DB_URL = DB_PATH# + "?debug=1&debugThreading=1"
|
DB_URL = DB_PATH# + "?debug=1&debugThreading=1"
|
||||||
|
|
||||||
class ExampleAccount(Account):
|
class ExampleAccount(Account):
|
||||||
login = StringCol(default = "")
|
login = StringCol(default="")
|
||||||
password = StringCol(default = None)
|
password = StringCol(default=None)
|
||||||
store_password = BoolCol(default = True)
|
store_password = BoolCol(default=True)
|
||||||
waiting_password_reply = BoolCol(default = False)
|
waiting_password_reply = BoolCol(default=False)
|
||||||
|
|
||||||
test_enum = EnumCol(default = "choice1", enumValues = ["choice1", "choice2", "choice3"])
|
test_enum = EnumCol(default="choice1", enumValues=["choice1", "choice2", "choice3"])
|
||||||
test_int = IntCol(default = 42)
|
test_int = IntCol(default=42)
|
||||||
|
|
||||||
def _get_register_fields(cls, real_class = None):
|
def _get_register_fields(cls, real_class=None):
|
||||||
def password_post_func(password):
|
def password_post_func(password):
|
||||||
if password is None or password == "":
|
if password is None or password == "":
|
||||||
return None
|
return None
|
||||||
@@ -55,107 +55,127 @@ class ExampleAccount(Account):
|
|||||||
if real_class is None:
|
if real_class is None:
|
||||||
real_class = cls
|
real_class = cls
|
||||||
return Account.get_register_fields(real_class) + \
|
return Account.get_register_fields(real_class) + \
|
||||||
[("login", "text-single", None, \
|
[("login", "text-single", None,
|
||||||
lambda field_value, default_func: account.mandatory_field(field_value), \
|
lambda field_value, default_func, bare_from_jid: \
|
||||||
lambda : ""), \
|
account.mandatory_field(field_value),
|
||||||
("password", "text-private", None, \
|
lambda : ""),
|
||||||
lambda field_value, default_func: password_post_func(field_value), \
|
("password", "text-private", None,
|
||||||
lambda : ""), \
|
lambda field_value, default_func, bare_from_jid: \
|
||||||
("store_password", "boolean", None, account.default_post_func, \
|
password_post_func(field_value),
|
||||||
lambda : True), \
|
lambda : ""),
|
||||||
("test_enum", "list-single", ["choice1", "choice2", "choice3"], \
|
("store_password", "boolean", None, account.default_post_func,
|
||||||
account.default_post_func, \
|
lambda : True),
|
||||||
lambda : "choice2"), \
|
("test_enum", "list-single", ["choice1", "choice2", "choice3"],
|
||||||
("test_int", "text-single", None, account.int_post_func, \
|
account.default_post_func,
|
||||||
|
lambda : "choice2"),
|
||||||
|
("test_int", "text-single", None, account.int_post_func,
|
||||||
lambda : 44)]
|
lambda : 44)]
|
||||||
|
|
||||||
get_register_fields = classmethod(_get_register_fields)
|
get_register_fields = classmethod(_get_register_fields)
|
||||||
|
|
||||||
class Example2Account(Account):
|
class Example2Account(Account):
|
||||||
test_new_int = IntCol(default = 42)
|
test_new_int = IntCol(default=42)
|
||||||
|
|
||||||
def _get_register_fields(cls, real_class = None):
|
def _get_register_fields(cls, real_class=None):
|
||||||
if real_class is None:
|
if real_class is None:
|
||||||
real_class = cls
|
real_class = cls
|
||||||
return Account.get_register_fields(real_class) + \
|
return Account.get_register_fields(real_class) + \
|
||||||
[("test_new_int", "text-single", None, account.int_post_func, \
|
[("test_new_int", "text-single", None, account.int_post_func,
|
||||||
lambda : 43)]
|
lambda : 43)]
|
||||||
get_register_fields = classmethod(_get_register_fields)
|
get_register_fields = classmethod(_get_register_fields)
|
||||||
|
|
||||||
class PresenceAccountExample(PresenceAccount):
|
class PresenceAccountExample(PresenceAccount):
|
||||||
DO_SOMETHING_ELSE = 2
|
DO_SOMETHING_ELSE = 2
|
||||||
possibles_actions = [PresenceAccount.DO_NOTHING, \
|
possibles_actions = [PresenceAccount.DO_NOTHING,
|
||||||
PresenceAccount.DO_SOMETHING, \
|
PresenceAccount.DO_SOMETHING,
|
||||||
DO_SOMETHING_ELSE]
|
DO_SOMETHING_ELSE]
|
||||||
|
|
||||||
def _get_presence_actions_fields(cls):
|
def _get_presence_actions_fields(cls):
|
||||||
"""See PresenceAccount._get_presence_actions_fields
|
"""See PresenceAccount._get_presence_actions_fields
|
||||||
"""
|
"""
|
||||||
return {'chat_action': (cls.possibles_actions, \
|
return {'chat_action': (cls.possibles_actions,
|
||||||
PresenceAccountExample.DO_SOMETHING_ELSE), \
|
PresenceAccountExample.DO_SOMETHING_ELSE),
|
||||||
'online_action': (cls.possibles_actions, \
|
'online_action': (cls.possibles_actions,
|
||||||
PresenceAccountExample.DO_SOMETHING_ELSE), \
|
PresenceAccountExample.DO_SOMETHING_ELSE),
|
||||||
'away_action': (cls.possibles_actions, \
|
'away_action': (cls.possibles_actions,
|
||||||
PresenceAccountExample.DO_SOMETHING_ELSE), \
|
PresenceAccountExample.DO_SOMETHING_ELSE),
|
||||||
'xa_action': (cls.possibles_actions, \
|
'xa_action': (cls.possibles_actions,
|
||||||
PresenceAccountExample.DO_SOMETHING_ELSE), \
|
PresenceAccountExample.DO_SOMETHING_ELSE),
|
||||||
'dnd_action': (cls.possibles_actions, \
|
'dnd_action': (cls.possibles_actions,
|
||||||
PresenceAccountExample.DO_SOMETHING_ELSE), \
|
PresenceAccountExample.DO_SOMETHING_ELSE),
|
||||||
'offline_action': (cls.possibles_actions, \
|
'offline_action': (cls.possibles_actions,
|
||||||
PresenceAccountExample.DO_SOMETHING_ELSE)}
|
PresenceAccountExample.DO_SOMETHING_ELSE)}
|
||||||
|
|
||||||
get_presence_actions_fields = classmethod(_get_presence_actions_fields)
|
get_presence_actions_fields = classmethod(_get_presence_actions_fields)
|
||||||
|
|
||||||
test_new_int = IntCol(default = 42)
|
test_new_int = IntCol(default=42)
|
||||||
|
|
||||||
def _get_register_fields(cls, real_class = None):
|
def _get_register_fields(cls, real_class=None):
|
||||||
if real_class is None:
|
if real_class is None:
|
||||||
real_class = cls
|
real_class = cls
|
||||||
return PresenceAccount.get_register_fields(real_class) + \
|
return PresenceAccount.get_register_fields(real_class) + \
|
||||||
[("test_new_int", "text-single", None, account.int_post_func, \
|
[("test_new_int", "text-single", None, account.int_post_func,
|
||||||
lambda : 43)]
|
lambda : 43)]
|
||||||
get_register_fields = classmethod(_get_register_fields)
|
get_register_fields = classmethod(_get_register_fields)
|
||||||
|
|
||||||
class AccountModule_TestCase(unittest.TestCase):
|
class AccountModule_TestCase(unittest.TestCase):
|
||||||
def test_default_post_func(self):
|
def test_default_post_func(self):
|
||||||
result = account.default_post_func("test", None)
|
result = account.default_post_func("test", None, "user1@jcl.test.com")
|
||||||
self.assertEquals(result, "test")
|
self.assertEquals(result, "test")
|
||||||
|
|
||||||
def test_default_post_func_default_value(self):
|
def test_default_post_func_default_value(self):
|
||||||
result = account.default_post_func("", lambda : "test")
|
result = account.default_post_func("", lambda : "test", "user1@jcl.test.com")
|
||||||
self.assertEquals(result, "test")
|
self.assertEquals(result, "test")
|
||||||
|
|
||||||
def test_default_post_func_default_value2(self):
|
def test_default_post_func_default_value2(self):
|
||||||
result = account.default_post_func(None, lambda : "test")
|
result = account.default_post_func(None, lambda : "test", "user1@jcl.test.com")
|
||||||
self.assertEquals(result, "test")
|
self.assertEquals(result, "test")
|
||||||
|
|
||||||
def test_int_post_func(self):
|
def test_int_post_func(self):
|
||||||
result = account.int_post_func("42", None)
|
result = account.int_post_func("42", None, "user1@jcl.test.com")
|
||||||
self.assertEquals(result, 42)
|
self.assertEquals(result, 42)
|
||||||
|
|
||||||
def test_int_post_func_default_value(self):
|
def test_int_post_func_default_value(self):
|
||||||
result = account.int_post_func("", lambda : 42)
|
result = account.int_post_func("", lambda : 42, "user1@jcl.test.com")
|
||||||
self.assertEquals(result, 42)
|
self.assertEquals(result, 42)
|
||||||
|
|
||||||
def test_int_post_func_default_value(self):
|
def test_int_post_func_default_value(self):
|
||||||
result = account.int_post_func(None, lambda : 42)
|
result = account.int_post_func(None, lambda : 42, "user1@jcl.test.com")
|
||||||
self.assertEquals(result, 42)
|
self.assertEquals(result, 42)
|
||||||
|
|
||||||
def test_mandatory_field_empty(self):
|
def test_mandatory_field_empty(self):
|
||||||
self.assertRaises(FieldError, \
|
self.assertRaises(FieldError,
|
||||||
account.mandatory_field, \
|
account.mandatory_field,
|
||||||
"")
|
"")
|
||||||
|
|
||||||
def test_mandatory_field_none(self):
|
def test_mandatory_field_none(self):
|
||||||
self.assertRaises(FieldError, \
|
self.assertRaises(FieldError,
|
||||||
account.mandatory_field, \
|
account.mandatory_field,
|
||||||
None)
|
None)
|
||||||
|
|
||||||
def test_mandatory_field_empty(self):
|
def test_mandatory_field_empty(self):
|
||||||
self.assertEquals(account.mandatory_field("value"), \
|
self.assertEquals(account.mandatory_field("value"),
|
||||||
"value")
|
"value")
|
||||||
|
|
||||||
class Account_TestCase(unittest.TestCase):
|
class InheritableAccount_TestCase(unittest.TestCase):
|
||||||
|
def test_get_register_fields(self):
|
||||||
|
"""Check if post functions and default functions execute correctly.
|
||||||
|
To be validated this test only need to be executed without any
|
||||||
|
exception.
|
||||||
|
"""
|
||||||
|
for (field_name,
|
||||||
|
field_type,
|
||||||
|
field_options,
|
||||||
|
field_post_func,
|
||||||
|
field_default_func) in self.account_class.get_register_fields():
|
||||||
|
if field_name is not None:
|
||||||
|
try:
|
||||||
|
field_post_func(field_default_func(), field_default_func, "user1@jcl.test.com")
|
||||||
|
except FieldError, error:
|
||||||
|
# this type of error is OK
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Account_TestCase(InheritableAccount_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)
|
||||||
@@ -163,6 +183,7 @@ class Account_TestCase(unittest.TestCase):
|
|||||||
Account.createTable(ifNotExists = True)
|
Account.createTable(ifNotExists = True)
|
||||||
ExampleAccount.createTable(ifNotExists = True)
|
ExampleAccount.createTable(ifNotExists = True)
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
self.account_class = Account
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
@@ -176,9 +197,9 @@ class Account_TestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_set_status(self):
|
def test_set_status(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
account11 = Account(user_jid = "test1@test.com", \
|
account11 = Account(user_jid="test1@test.com",
|
||||||
name = "account11", \
|
name="account11",
|
||||||
jid = "account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
account11.status = account.OFFLINE
|
account11.status = account.OFFLINE
|
||||||
self.assertEquals(account11.status, account.OFFLINE)
|
self.assertEquals(account11.status, account.OFFLINE)
|
||||||
# TODO : test first_check attribute
|
# TODO : test first_check attribute
|
||||||
@@ -186,14 +207,14 @@ class Account_TestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def test_set_status_live_password(self):
|
def test_set_status_live_password(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
account11 = ExampleAccount(user_jid = "test1@test.com", \
|
account11 = ExampleAccount(user_jid="test1@test.com",
|
||||||
name = "account11", \
|
name="account11",
|
||||||
jid = "account11@jcl.test.com", \
|
jid="account11@jcl.test.com",
|
||||||
login = "mylogin", \
|
login="mylogin",
|
||||||
password = "mypassword", \
|
password="mypassword",
|
||||||
store_password = False, \
|
store_password=False,
|
||||||
test_enum = "choice3", \
|
test_enum="choice3",
|
||||||
test_int = 21)
|
test_int=21)
|
||||||
account11.waiting_password_reply = True
|
account11.waiting_password_reply = True
|
||||||
account11.status = account.OFFLINE
|
account11.status = account.OFFLINE
|
||||||
self.assertEquals(account11.status, account.OFFLINE)
|
self.assertEquals(account11.status, account.OFFLINE)
|
||||||
@@ -201,7 +222,7 @@ class Account_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(account11.password, None)
|
self.assertEquals(account11.password, None)
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
class PresenceAccount_TestCase(unittest.TestCase):
|
class PresenceAccount_TestCase(InheritableAccount_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)
|
||||||
@@ -231,9 +252,11 @@ class PresenceAccount_TestCase(unittest.TestCase):
|
|||||||
fields = self.account_class.get_presence_actions_fields()
|
fields = self.account_class.get_presence_actions_fields()
|
||||||
self.assertEquals(len(fields), 6)
|
self.assertEquals(len(fields), 6)
|
||||||
(possibles_actions, chat_default_action) = fields["chat_action"]
|
(possibles_actions, chat_default_action) = fields["chat_action"]
|
||||||
self.assertEquals(possibles_actions, self.account_class.possibles_actions)
|
self.assertEquals(possibles_actions,
|
||||||
|
self.account_class.possibles_actions)
|
||||||
(possibles_actions, online_default_action) = fields["online_action"]
|
(possibles_actions, online_default_action) = fields["online_action"]
|
||||||
self.assertEquals(possibles_actions, self.account_class.possibles_actions)
|
self.assertEquals(possibles_actions,
|
||||||
|
self.account_class.possibles_actions)
|
||||||
|
|
||||||
def test_possibles_actions(self):
|
def test_possibles_actions(self):
|
||||||
for (field_name, \
|
for (field_name, \
|
||||||
@@ -243,12 +266,13 @@ class PresenceAccount_TestCase(unittest.TestCase):
|
|||||||
default_func) in self.account_class.get_register_fields()[1:]:
|
default_func) in self.account_class.get_register_fields()[1:]:
|
||||||
if possibles_actions is not None:
|
if possibles_actions is not None:
|
||||||
for possible_action in possibles_actions:
|
for possible_action in possibles_actions:
|
||||||
self.assertEquals(post_func(possible_action, default_func),
|
self.assertEquals(post_func(possible_action, default_func,
|
||||||
|
"user1@jcl.test.com"),
|
||||||
int(possible_action))
|
int(possible_action))
|
||||||
self.assertTrue(str(default_func()) in possibles_actions)
|
self.assertTrue(str(default_func()) in possibles_actions)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
post_func("42", default_func)
|
post_func("42", default_func, "user1@jcl.test.com")
|
||||||
default_func()
|
default_func()
|
||||||
except FieldError, error:
|
except FieldError, error:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user