Does not send presence if it has not change

darcs-hash:20080514063321-86b55-befb7d76016153a5da1f1190f1d498b5a8813c47.gz
This commit is contained in:
David Rousselie
2008-05-14 08:33:21 +02:00
parent 9760b58737
commit e1c9919390
2 changed files with 16 additions and 7 deletions

View File

@@ -387,13 +387,13 @@ class AccountManager(object):
"""Send available presence to account's user and ask for password
if necessary"""
result = []
model.db_connect()
old_status = _account.status
_account.status = account.ONLINE
if _account.error is not None:
_account.status = account.DND
elif not _account.enabled:
_account.status = account.XA
if old_status != _account.status:
result.extend(self.get_presence(from_jid=_account.jid,
to_jid=_account.user.jid,
status=_account.status_msg,
@@ -405,7 +405,6 @@ class AccountManager(object):
and old_status == account.OFFLINE \
and _account.password == None :
result.extend(self.ask_password(_account, lang_class))
model.db_disconnect()
return result
def probe_all_accounts_presence(self):

View File

@@ -3189,6 +3189,16 @@ class AccountManager_TestCase(JCLTestCase):
self.assertEquals(presence.children.name, "show")
self.assertEquals(presence.children.content, "online")
def test_get_account_presence_available_no_change(self):
"""Test when presence status does not change"""
_account = Account(user=User(jid="user1@test.com"),
name="account11",
jid="account11@jcl.test.com")
_account.status = account.ONLINE
result = self.account_manager.get_account_presence_available(\
_account, _account.default_lang_class)
self.assertEquals(len(result), 0)
def suite():
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.makeSuite(JCLComponent_TestCase, 'test'))